'how to manage the timezone which are not directly supported in java

we are getting the ZoneId object by passing the id string -> ZoneId.of("US/Alaska")

While getting the timezone ids from java after passing the location name, we get error that "Exception in thread "main" java.time.zone.ZoneRulesException: Unknown time-zone ID: EST"

We get this exception for multiple location like -> EST, America/Argentina, America/Indiana, America/Kentucky, America/North_Dakota

What is the best way to handle such cases? is it good idea to get the ZoneId object by passing location Id?



Solution 1:[1]

You should specify cities not countries (most of them are cities), for example which city of Argentina?

America/Argentina/Buenos_Aires
America/Argentina/Catamarca
America/Argentina/ComodRivadavia
America/Argentina/...

A list of valid Java timezones can be found here (refer to the comments for better reference):
https://garygregory.wordpress.com/2013/06/18/what-are-the-java-timezone-ids/


UPDATE:

In order to get all available zone ids:

Set<String> zoneIds = ZoneId.getAvailableZoneIds();
System.out.println("Available Zone Ids: \n" + String.join("\n", zoneIds));

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1