September 2019
Intermediate to advanced
816 pages
18h 47m
English
The LocalDateTime class exposes a series of of() methods that are useful for obtaining a different kind of instance of LocalDateTime. For example, a LocalDateTime class that is obtained from the year, month, day, hour, minute, second, or nanosecond looks like this:
LocalDateTime ldt = LocalDateTime.of(2020, 4, 1, 12, 33, 21, 675);
So, the preceding code combines date and time as arguments of the of() method. In order to combine date and time as objects, the solution can take advantage of the following of() method:
public static LocalDateTime of(LocalDate date, LocalTime time)
This results in LocalDate and LocalTime, as in the following:
LocalDate localDate = LocalDate.now(); // 2019-Feb-24 ...