Ted pottel :
I have the time in milliseconds and I need to convert it to a ZonedDateTime object.
I have the following code
long m = System.currentTimeMillis();
LocalDateTime d = LocalDateTime.millsToLocalDateTime(m);
The line
LocalDateTime d = LocalDateTime.millsToLocalDateTime(m);
gives me a error saying methed millsToLocalDateTime is undefined for type LocalDateTime
xingbin :
ZonedDateTime
and LocalDateTime
are different.
If you need LocalDateTime
, you can do it this way:
long m = ...;
Instant instant = Instant.ofEpochMilli(m);
LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());