Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4415194

(tz) RFE: No way to create a decent time-zone list

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.3.0
    • core-libs



      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)
      ======================================================================

            naoto Naoto Sato
            kryansunw Kevin Ryan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: