If you have milliseconds from an era and want to convert them to a local date using the current local time zone, you can use
LocalDate date = Instant.ofEpochMilli(longValue).atZone(ZoneId.systemDefault()).toLocalDate();
but keep in mind that even the default time zone for systems can change, so the same long value can give different results in subsequent runs even on the same computer.
Also, keep in mind that LocalDate , unlike java.util.Date , does represent a date, not a date and time.
Otherwise, you can use LocalDateTime :
LocalDateTime date = LocalDateTime.ofInstant(Instant.ofEpochMilli(longValue), ZoneId.systemDefault());
Holger Feb 03 '16 at 20:27 2016-02-03 20:27
source share