ZonedDateTime of(LocalDateTime localDateTime, ZoneId zone)
creates
an instance of ZonedDateTime from a local date-time.
of
has the following syntax.
public static ZonedDateTime of(LocalDateTime localDateTime, ZoneId zone)
The following example shows how to use of
.
import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZonedDateTime; // ww w . j a v a 2 s . c om public class Main { public static void main(String[] args) { ZonedDateTime z = ZonedDateTime.of(LocalDateTime.now(),ZoneId.systemDefault()); System.out.println(z); LocalDateTime timePoint = LocalDateTime.now(); ZoneId id = ZoneId.of("Europe/Paris"); ZonedDateTime zoned = ZonedDateTime.of(timePoint, id); System.out.println(zoned); } }
The code above generates the following result.