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