views:

159

answers:

0

My Android app is using this code to get the short name of the timezone in which the handset is located.

String shortDisplayName = Calendar.getInstance().getTimeZone().getDisplayName(false, TimeZone.SHORT);

For my user in Strasbourg, France, shortDisplayName is "HNEC" (I haven't learned yet exactly which locale is in play). I'm trying to determine exactly which TimeZone has that short name. So, I threw together some quick test code:

String[] ids = TimeZone.getAvailableIDs();
Locale[] locales = Locale.getAvailableLocales();
for (String id : ids) {
    TimeZone timeZone = TimeZone.getTimeZone(id);
    int rawOffset = timeZone.getRawOffset();
    for (Locale locale : locales) {
        String shortDisplayName = timeZone.getDisplayName(false, TimeZone.SHORT, locale);
        if (shortDisplayName.equalsIgnoreCase("HNEC")) {
            System.out.println(id + " | " + shortDisplayName + " | " + rawOffset);
        }
    }
}

When I run that code, no lines are printing. That is, no timezones, using any locale, resolve to a shortname of "HNEC"? How can I figure out which TimeZone has a short name of "HNEC"?