I wrote an Android application that needs the short name of the time zone in which the phone is currently located.
I am using the following code:
String timeZone = Calendar.getInstance().getTimeZone().getDisplayName(false, TimeZone.SHORT);
When working in Chicago, this returns "CST". In New York "EST". In Strasbourg, France , he returns "HNEC" ( Heure Normale de l'Europe Centrale in French ).
The time zone at this place is referred to by some as "Central European Time" (see Wikipedia Europe Time Zone ).
I pass timeZone to a third-party system that insists on getting a "CET" (not an "HNEC"). Is there an API call that I can rely on to return the three-letter (and, I think, “more modern”) short name of the time zone?
As my code works in an increasing number of locations, I assume this problem will occur elsewhere.
I really hope to avoid saving some kind of three-letter short name map with a four-letter time zone.
lance source share