Java Date Time Java Java API
Class:
java.time.LocalDateTime
Method:
public static LocalDateTime ofInstant(Instant instant,
ZoneId zone)
This static method returns an instance of LocalDateTime from an Instant and zone ID.
Instant is an instantaneous point on the time-line. As LocalDateTime field values might be different for different regions of the world at the same instant, we must need a ZoneId information as well to get a region specific LocalDateTime.
Examples
package com.logicbig.example.localdatetime;
import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId;
public class OfInstantExample {
public static void main (String... args) { Instant instant = Instant.now(); LocalDateTime dt = LocalDateTime.ofInstant(instant, ZoneId.of("America/New_York")); System.out.println(dt); } }
Output2017-05-01T17:27:21.062
|