ZonedDateTime ofInstant(LocalDateTime localDateTime, ZoneOffset offset, ZoneId zone) example
Description
ZonedDateTime ofInstant(LocalDateTime localDateTime, ZoneOffset offset, ZoneId zone)
creates ZonedDateTime from the local date-time and offset.
Syntax
ofInstant
has the following syntax.
public static ZonedDateTime ofInstant(LocalDateTime localDateTime,
ZoneOffset offset,
ZoneId zone)
Example
The following example shows how to use ofInstant
.
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
/* w ww .ja v a2s. co m*/
public class Main {
public static void main(String[] args) {
ZonedDateTime z = ZonedDateTime.ofInstant(LocalDateTime.now(),ZoneOffset.UTC,ZoneId.systemDefault());
System.out.println(z);
}
}
The code above generates the following result.