1224043200000
refers to the number of milliseconds from 1970-01-01T00:00:00Z
and is equivalent to 2008-10-15T04:00:00Z
at UTC.
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
public class Main {
public static void main(final String[] args) {
Instant instant = Instant.ofEpochMilli(1224043200000L);
System.out.println(instant);
// Get ZonedDateTime from Instant
// I have used time-zone of Europe/London. Use a time-zone as per your
// requirement. You can also use ZoneId.systemDefault()
ZonedDateTime zdt = ZonedDateTime.ofInstant(instant, ZoneId.of("Europe/London"));
// Get OffsetDateTime from ZonedDateTime
OffsetDateTime odt = zdt.toOffsetDateTime();
// Get LocalDateTime from ZonedDateTime if required. However, note that
// LocalDateTime drops the valuable information, time-zone from ZonedDateTime
// and zone-offset from OffsetDateTime
LocalDateTime ldt = zdt.toLocalDateTime();
System.out.println(ldt);
}
}
Output:
2008-10-15T04:00:00Z
2008-10-15T05:00
Backport of the Java SE 8 date-time classes to Java SE 6 and 7:
Check ThreeTen-Backport and How to use ThreeTenABP