一.时间类
二.获取所有的时区
1.获取所有的时区
Set<String> zoneIds = ZoneId.getAvailableZoneIds();
System.out.println(zoneIds.size());
根据打印的结果可以看到java类中一共有603个时区。
三.获取当前系统默认的时区
ZoneId zoneId = ZoneId.systemDefault();
System.out.println(zoneId); //Asia/Shanghai
四.获取指定的时区
3.获取指定的时区
ZoneId zoneId1 = ZoneId.of("Asia/Pontianak");
System.out.println(zoneId1); //Asia/Shanghai
五.Instant:时间戳
1.获取标准时间
Instant now = Instant.now();
System.out.println(now); //2024-06-13T14:47:48.888Z
2.获取时间的原点
Instant Instant1 = Instant.ofEpochMilli(0L);
System.out.println(Instant1); //1970-01-01T00:00:00Z
3.距离时间原点多少秒
Instant Instant2 = Instant.ofEpochSecond(1L);
System.out.println(Instant2); //1970-01-01T00:00:00Z