JDK-4415194 : (tz) RFE: No way to create a decent time-zone list
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 1.3.0
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: generic
  • CPU: generic
  • Submitted: 2001-02-14
  • Updated: 2017-02-08
  • Resolved: 2017-02-08
Related Reports
Relates :  
Relates :  
Description

Name: krC82822			Date: 02/14/2001


java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

In my application, I'd like to present a meaningful, internationalized list of
time zones for the user to pick from.  The obvious code to do this would be
something like this:

    String[] ids = TimeZone.getAvailableIDs();
    String[] zoneNames = new String[ids.length];
    
    for (int i = 0; i < ids.length; i++) {
        TimeZone zone = TimeZone.getTimeZone(ids[i]);
        zoneNames[i] = zone.getDisplayName(false, TimeZone.LONG);
    }

I'd then add the resulting strings to a JList or a JComboBox or something.

This code produces completely unacceptable results, as follows:

o  I get a list of over 200 time zones, many of which are duplicates with
different IDs.

o  I get identical display names for different time zones.  For instance, I
get "Mountain Standard Time" for both America/Denver and America/Phoenix, even
though America/Denver observes daylight saving time and America/Phoenix
doesn't.  This is also (somewhat more understandably) true of the automatically-
generated display names: I get "GMT+01:00" for over thirty-five different time
zones comprising five different sets of daylight-saving time rules.

o  I get back different display names for identical time zones.  For instance,
there are eighteen different time zones that don't observer daylight saving
time and have a GMT offset of zero, but I only see "Greenwich Mean Time" as the
display for "GMT" and "Africa/Casablanca".  I get "GMT+00:00" for all the
others.

o  The time-zone list appears to come back sorted by GMT offset, but isn't
perfectly sorted, making it more difficult to filter out duplicate time zones.

o  Why are English display names provided for Europe/Paris and Europe/Bucharest
but not for Europe/London, Europe/Berlin (which seems to encompass most of
Europe), or Europe/Istanbul?
(Review ID: 116831) 
======================================================================

Comments
Does not seem a popular demand.
08-02-2017

WORK AROUND Name: krC82822 Date: 02/14/2001 I basically have three choices of workarounds: 1) Postprocess the list I get back from TimeZone.getIDs() to weed out the duplicates, taking care to keep the ones that actually have English display names, and differentiate the different zones with the same names by adding city names to the display names by parsing the internal IDs. 2) Blow off TimeZone.getDisplayName() altogether and provide my own mechanism for providing displayable time zone names. This might involve drastically limiting the user's choice of available time zones. 3) Use the internal IDs (possibly with some extra massaging) as display names. ====================================================================== > o I get a list of over 200 time zones, many of which are duplicates with > different IDs. Workaround is to remove the JDK1.1 3-letter time zone IDs. Exceptions of the 3-letter time zone IDs are GMT, UTC and WET (see 4348058). There are a few aliases defined for following the Olson public zoneinfo changes. masayoshi.okutsu@Eng 2001-02-15
15-02-2001

EVALUATION > o I get identical display names for different time zones. For instance, I > get "Mountain Standard Time" for both America/Denver and America/Phoenix, even > though America/Denver observes daylight saving time and America/Phoenix > doesn't. This is also (somewhat more understandably) true of the automatically- > generated display names: I get "GMT+01:00" for over thirty-five different time > zones comprising five different sets of daylight-saving time rules. A time zone ID and a time zone display name are different. It's correct to call the standard time of both the time zones "Mountain Standard Time". (At least, there are no different names defined for the standard time.) During the daylight saving time of America/Denver, its display name changes to "Mountain Daylight Time". > o I get back different display names for identical time zones. For instance, > there are eighteen different time zones that don't observer daylight saving > time and have a GMT offset of zero, but I only see "Greenwich Mean Time" as the > display for "GMT" and "Africa/Casablanca". I get "GMT+00:00" for all the > others. > o Why are English display names provided for Europe/Paris and Europe/Bucharest > but not for Europe/London, Europe/Berlin (which seems to encompass most of > Europe), or Europe/Istanbul? > (Review ID: 116831) These problems were fixed in Ladybird. See 4112924. Note that some time zones have different IDs and display names under the same GMT offset and (current) DST rules. For example, Japan Standard Time and Korea Standard Time have the same GMT offset and no DST rules. But different IDs and names are given to those time zones. > o The time-zone list appears to come back sorted by GMT offset, but isn't > perfectly sorted, making it more difficult to filter out duplicate time zones. Currently, it's not spec to return the available time zone IDs in the order of GMT raw offsets. In any case, a better API is required to provide UI for time zone selection. masayoshi.okutsu@Eng 2001-02-15
15-02-2001