开发者

How to find the timezone with "HNEC" short name?

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.getAvaila开发者_运维百科bleIDs();
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"?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜