0

I am writing a Java program. I only have a list of time zone names and I wanted to convert this in Java Time API supported Zone ID

For example, I want to convert following list

US Eastern Standard Time
Central Standard Time

into the below list US\EST US\Centeral

My ultimate goal is to have TimeZone object using the windows time zone name

  • The fundamental issue is that the names you mention do **not** directly map to unique Olson IDs. The names you use more closely map to zone rule names, which can apply to any given Time Zone ID at *some time*, but not at others. – Joachim Sauer Aug 06 '20 at 08:11
  • @JoachimSauer: It's a bit weirder than that - Windows uses "US Eastern Standard Time" to refer to Eastern time zones *including in DST*. It's a bizarre kind of ID, but that's what Windows has decided to do :( See the info in https://stackoverflow.com/tags/timezoneinfo for more details. – Jon Skeet Aug 06 '20 at 08:22
  • 1
    @JonSkeet: I ... did not know that. Having dealt with timezones way to much on Android I thought I knew all the nasty little details, but that's beyond what I expected. – Joachim Sauer Aug 06 '20 at 08:26
  • 1
    @JoachimSauer: First rule of time zones: there are *always* more nasty little details. (The two I'm particularly fond of are Ireland observing negative DST, and the Japanese transitions at "25:00" from 1948 to 1951.) – Jon Skeet Aug 06 '20 at 09:09
  • @JonSkeet: my favorite is `Antarctica/Troll` having two different daylights saving time offsets (i.e. 3 total offsets) during the year and most libraries just politely ignoring that fact, because it would mess up everything. – Joachim Sauer Aug 06 '20 at 09:29
  • 1
    You need to use the [CLDR Windows zones](https://github.com/unicode-org/cldr/blob/master/common/supplemental/windowsZones.xml) for conversions. Try the ICU4J method [`TimeZone.getIDForWindowsID`](https://unicode-org.github.io/icu-docs/apidoc/released/icu4j/com/ibm/icu/util/TimeZone.html#getIDForWindowsID-java.lang.String-java.lang.String-). – Matt Johnson-Pint Aug 07 '20 at 05:43
  • Does this answer your question? [How to translate between windows and IANA timezones in java](https://stackoverflow.com/questions/31450236/how-to-translate-between-windows-and-iana-timezones-in-java) – Ole V.V. Aug 09 '20 at 05:46

0 Answers0