import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
public class LocalDateTest {
public static void main(String[] args) {
LocalDateTime localDateTime = LocalDateTime.now();
long l1 = localDateTime.atZone(ZoneId.of("Asia/Shanghai")).toInstant().toEpochMilli();
System.out.println("目前毫秒數:"+l1);
LocalDate localDate = LocalDate.now();
System.out.println("目前日期:"+localDate);
LocalDate localDate1 = localDate.plusDays(1);
System.out.println("目前日期下一天:"+localDate1);
LocalDateTime localDateTime1 = localDate1.atStartOfDay();
System.out.println("下一天的淩晨:"+localDateTime1);
long milli = localDateTime1.atZone(ZoneId.of("Asia/Shanghai")).toInstant().toEpochMilli();
System.out.println("下一天的淩晨毫秒數:"+milli);
System.out.println("目前時間到第二天淩晨的毫秒數"+(milli-l1));
}
}
// 輸出
目前毫秒數:1576736181944
目前日期:2019-12-19
目前日期下一天:2019-12-20
下一天的淩晨:2019-12-20T00:00
下一天的淩晨毫秒數:1576771200000
目前時間到第二天淩晨的毫秒數35018056