June 2018
Beginner
722 pages
18h 47m
English
The class LocalDateTime contains both date and time, and has all the methods the classes LocalDate and LocalTime have, so we are not going to repeat them here. We will only show how an object of LocalDateTime can be created:
System.out.println(LocalDateTime.now()); //2018-04-14T21:59:00.142804ZoneId zoneId = ZoneId.of("Asia/Tokyo");System.out.println(LocalDateTime.now(zoneId)); //prints: 2018-04-15T12:59:00.146038LocalDateTime ldt1 = LocalDateTime.parse("2020-02-23T20:23:12");System.out.println(ldt1); //prints: 2020-02-23T20:23:12DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm:ss");LocalDateTime ldt2 = LocalDateTime.parse("23/02/2020 20:23:12", formatter);System.out.println(ldt2); //prints: ...
Read now
Unlock full access