September 2019
Intermediate to advanced
816 pages
18h 47m
English
Converting from Date to DateLocalTime is the same as converting from Date to LocalDate, apart from the fact that the solution should call the toLocalDateTime() method as follows:
// e.g., 2019-03-01T07:25:25.624public static LocalDateTime dateToLocalDateTime(Date date) { return dateToInstant(date).atZone( DEFAULT_TIME_ZONE).toLocalDateTime();}
Converting from LocalDateTime to Date is straightforward. Just apply the system default time zone and call toInstant():
// e.g., Fri Mar 01 07:25:25 EET 2019public static Date localDateTimeToDate(LocalDateTime localDateTime) { return Date.from(localDateTime.atZone( DEFAULT_TIME_ZONE).toInstant());}