1LocalDateTime now = LocalDateTime.now();
2System.out.println(now);
3System.out.println("ZoneId.systemDefault(): " + ZoneId.systemDefault());
4
5// convert LocalDateTime to ZonedDateTime, with default system zone id
6ZonedDateTime zonedDateTime = now.atZone(ZoneId.systemDefault());
7
8// convert LocalDateTime to ZonedDateTime, with specified zoneId
9ZonedDateTime europeDateTime = zonedDateTime.withZoneSameInstant(ZoneId.of("Europe/Kaliningrad"));
10System.out.println(europeDateTime);
11
12// convert LocalDateTime to ZonedDateTime, with specified off set
13ZonedDateTime offSetNegative5 = now.atOffset(ZoneOffset.of("-05:00")).toZonedDateTime();
14System.out.println(offSetNegative5);
15
16// display all zone ids
17//ZoneId.getAvailableZoneIds().forEach(System.out::println);
18
19// output
20/*
212021-03-23T16:43:32.010069453
22ZoneId.systemDefault(): Asia/Kuala_Lumpur
232021-03-23T10:43:32.010069453+02:00[Europe/Kaliningrad]
242021-03-23T16:43:32.010069453-05:00
25*/