Java doesn't have information about all IANA time zones

Viewed 4174

I'm trying to map the values that come from the Front-End to ZoneId class like this:

Optional.ofNullable(timeZone).map(ZoneId::of).orElse(null)

For most time zones it works fine, however, for some values Java throws exception:

java.time.zone.ZoneRulesException: Unknown time-zone ID: America/Punta_Arenas

However, it is a valid time-zone according to IANA: https://www.iana.org/time-zones

Zone America/Punta_Arenas -4:43:40 - LMT 1890

I was thinking about using offset for such time-zones (just to hardcode values), but I guess there should be more convenient way to solve the issue. Is there a way Java can handle that?

Other timezones that are not supported:

  • America/Punta_Arenas
  • Asia/Atyrau
  • Asia/Famagusta
  • Asia/Yangon
  • EST
  • Europe/Saratov
  • HST
  • MST
  • ROC

My Java version: "1.8.0_121" Java(TM) SE Runtime Environment (build 1.8.0_121-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

1 Answers
Related