How to convert Date into LocalDateTime in Java 8

The conversion between java.util.Data and LocaleDateTime is really simple in java 8,  check the following example.

Date to LocalDateTime

Date date = new Date();
Instant instant = date.toInstant();
LocalDateTime ldt = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());


LocalDateTime to Date

LocalDateTime ldt =;
ZonedDateTime zdt = ldt.atZone(ZoneId.systemDefault());
Date date = Date.from(zdt.toInstant());



You like this content ? Share it with you entourage !

Leave a Reply

Your email address will not be published.