OffsetDateTime ofInstant(Instant instant, ZoneId zone)
creates
an instance of OffsetDateTime from an Instant and zone ID.
ofInstant
has the following syntax.
public static OffsetDateTime ofInstant(Instant instant, ZoneId zone)
The following example shows how to use ofInstant
.
import java.time.Instant; import java.time.OffsetDateTime; import java.time.ZoneId; /* w w w. j a v a 2 s .co m*/ public class Main { public static void main(String[] args) { OffsetDateTime o = OffsetDateTime.ofInstant(Instant.now(),ZoneId.systemDefault()); System.out.println(o); } }
The code above generates the following result.