I have a table in SQL server which stores the TimeZone codes as the format listed here: TimeZone Microsoft. I wonder if there is a way to get this TimeZone code correctly in Java using the method TimeZone.getTimeZone("")
. As the TimeZone codes in Java is not the same as it is in SQL (Available TimeZones in Java).
Or is there a way to return the time offset in SQL server by the TimeZone code? Thanks
There's mapping information between Windows time zone IDs and IANA IDs in CLDR - it's reasonably easy to read the XML, and you may well find there's a Java library around to parse this for you.
However, it's worth being aware that the time zone mappings aren't perfect: the Windows time zone data is basically not the same source as IANA, and some zones will map to different offsets for some periods. They're updated on different schedules, too.
See more on this question at Stackoverflow