Java Date Time Java Java API
java.time.OffsetDateTime
public static OffsetDateTime ofInstant(Instant instant, ZoneId zone)
public static OffsetDateTime ofInstant(Instant instant,
ZoneId zone)
Returns an instance of OffsetDateTime from an Instant and zone ID.
package com.logicbig.example.offsetdatetime;import java.time.Instant;import java.time.OffsetDateTime;import java.time.ZoneId;public class OfInstantExample { public static void main (String... args) { Instant i = Instant.now(); OffsetDateTime d = OffsetDateTime.ofInstant(i, ZoneId.systemDefault()); System.out.println(d); OffsetDateTime d2 = OffsetDateTime.ofInstant(Instant.EPOCH, ZoneId.of("+12")); System.out.println(d2); }}
2017-05-01T16:16:26.645-05:001970-01-01T12:00+12:00