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?
CodePudding user response:
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:
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));