September 2019
Intermediate to advanced
816 pages
18h 47m
English
Starting with JDK 8, a convenient solution to get the current local date-time in the default time zone is to call the ZonedDateTime.now() method:
ZonedDateTime zlt = ZonedDateTime.now();
So, this is the current date in the default time zone. Furthermore, this date should be displayed in all the available time zones that are obtained via the ZoneId class:
Set<String> zoneIds = ZoneId.getAvailableZoneIds();
Finally, the code can loop the zoneIds, and for each zone id, it can call the ZonedDateTime.withZoneSameInstant(ZoneId zone) method. This method returns a copy of this date-time with a different time zone, retaining the instant:
public static List<String> localTimeToAllTimeZones() { List<String> result = new ArrayList<>(); ...Read now
Unlock full access