Date – DateLocalTime

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.624
public 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 2019
public static Date localDateTimeToDate(LocalDateTime localDateTime) {

return Date.from(localDateTime.atZone(
DEFAULT_TIME_ZONE).toInstant());
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.21.158