ZoneId
zoneId zoneId = ZoneId . systemDefault ( ) ;
system. out. println ( zoneId. getId ( ) ) ;
system. out. println ( zoneId) ;
system. out. println ( ZoneId . getAvailableZoneIds ( ) ) ;
ZoneId zoneId1 = ZoneId . of ( "America/New_York" ) ;
ZonedDateTime now = ZonedDateTime . now ( zoneId1) ;
system. out. println ( now) ;
ZonedDateTime now1 = ZonedDateTime . now ( Clock . systemUTC ( ) ) ;
system. out. println ( now1) ;
ZonedDateTime now2 = ZonedDateTime . now ( ) ;
system. out. println ( now2) ;
Instant
Instant now = Instant . now ( ) ;
long second = now. getEpochSecond ( ) ;
system. out. println ( second) ;
int nano = now. getNano ( ) ;
system. out. println ( nano) ;
system. out. println ( now) ;
Instant instant = now. plusNanos ( 111 ) ;
Instant now1 = Instant . now ( ) ;
Instant now2 = Instant . now ( ) ;
DataTimeFormatter
DateTimeFormatter formatter = DateTimeFormatter . ofPattern ( "yyyy年MN月dd日 HH:mm:ss" ) ;
LocalDateTime now = LocalDateTime . now ( ) ;
system. out. println ( now) ;
String rs = formatter. format ( now) ;
system. out. println ( rs) ;
String rs2 = now. format ( formatter) ;
system. out. println ( rs2) ;
string dateStr = "2029年12月12日12:12:11" ;
LocalDateTime ldt = LocalDateTime . parse ( dateStr, formatter) ;
system. out. println ( ldt) ;
Period
LocalDate start = LocalDate . of ( 2029 , 8 , 10 ) ;
LocalDate end = LocalDate . of ( 2029 , 12 , 15 ) ;
Period period = Period . between ( start, end) ;
system. out. println ( period. getYears ( ) ) ;
system. out. println ( period. getMonths ( ) ) ;
system. out. println ( period. getDays ( ) ) ;
Duration
LocalDateTime start = LocalDateTime . of ( 2825 ,11 , 11 , 11 , 10 ,10 ) ;
LocalDateTime end = LocalDateTime . of ( 2025 , 11 , 11 , 11 , 11 ,11 ) ;
Duration duration = Duration . between ( start, end) ;
system. out. println ( duration. toDays ( ) ) ;
system. out. println ( duration. toHours ( ) ) ;
system. out. println ( duration. toMinutes ( ) ) ;
system. out. println ( duration. toSeconds ( ) ;
System . out. println ( duration. toMillis ( ) ;
system. out. println ( duration. toNanos ( ) ) ;