LocalDateTime atZone(ZoneId zone)
combines this date-time
with a time-zone to create a ZonedDateTime.
atZone
has the following syntax.
public ZonedDateTime atZone(ZoneId zone)
The following example shows how to use atZone
.
import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZonedDateTime; // w ww .j a v a 2 s. c om public class Main { public static void main(String[] args) { LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 00); ZonedDateTime b = a.atZone(ZoneId.systemDefault()); System.out.println(b); } }
The code above generates the following result.