2

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?

Onki
  • 1,879
  • 6
  • 38
  • 58
  • 1
    What did you want for EST? Australian or North American Eastern Standard Time? With or without respecting daylight saving time? For the others they seem to consist of more time zones each, possibly only in order to treat historic data correctly. – Ole V.V. Apr 18 '22 at 07:02

1 Answers1

3

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));
Mehdi Rahimi
  • 1,453
  • 5
  • 20
  • 31