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();
L
You cannot create extension methods in Java. If you want to define a separate method for this create a Utility class:
class DateUtils{
public static ZonedDateTime millsToLocalDateTime(long m){
ZoneId zoneId = ZoneId.systemDefault();
Instant instant = Instant.ofEpochSecond(m);
ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(instant, zoneId);
return zonedDateTime;
}
}
From your other class call
DateUtils.millsToLocalDateTime(89897987989L);