tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject [OT] Displaying Time Zones for user preferences
Date Wed, 21 Dec 2011 16:43:59 GMT
Hash: SHA1


We're getting to the point in our project where allowing users to
identify their own time zone so we can display adjusted timestamps is
something we can no longer do without. I'm trying to figure out how to
display a list of time zones in a drop-down list for users to pick.

Java's TimeZone class provides a static method, getAvailableIDs, that
returns the huge list of time zones that the current JVM knows about.
Then, I can use this list to fetch each TimeZone object by id and
shove them into a list to display on the screen. So far, so good.

To display, I have two options: use the "ID" which is usually of the
form "America/New_York" or use the "display name" which varies wildly
from zone to zone.

Here's an example of a few time zones that get returned from my JVM
(Oracle Java 1.6.0_26-b03 on a Debian Squeeze system):

ID                 Display Name (English)
ACT                Central Standard Time (Northern Territory)
AET                Eastern Standard Time (New South Wales)
AGT                Argentine Time
ART                Eastern European Time
AST                Alaska Standard Time
Africa/Abidjan     Greenwich Mean Time
Africa/Accra       Ghana Mean Time
America/Chicago    Central Standard Time
CST                Central Standard Time

Already, I can see a few problems:

1. Time zones are repeated with different IDs. That might not be such
   a big deal, since some people might like to look for "CST" and others
   might be looking for "America/Chicago". But including both requires
   the list to be very long.

2. If I go with "display name" instead of "id", then I have to decide
   which id to use when there are many choices. For instance,
   "Greenwich Mean Time" gets used a lot, but has lots of ids. If
   I arbitrarily choose "Africa/Abidjan" as the id to use for that
   label, then everyone who expected GMT might suddenly find their
   timestamps off if the Abidjanese people decide in the future
   to abandon GMT.

3. You can't see it, but the "ids" are not localized. The "display name"
   is available for many languages directly from the JVM but not the
   id. That means that the nice labels like "America/Chicago" will
   always have those labels, regardless of the user's display language.
   Not ideal.

4. We (the US) are currently not in DST, so "CST" is displayed
   and not "CDT". I checked, and it looks like there is no
   "CDT" time zone so during DST it will still say "CST" which
   probably nobody but me will notice.

I feel like I've got a Catch-22, here: despite the wealth of
information provided by the JVM, I think I might still have to just
have a giant list of supported time zones and hand-localize them,
especially if I want to have "America/New York"-style labels.

Does anyone have any suggestions?

- -chris
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools -
Comment: Using GnuPG with Mozilla -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message