tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <>
Subject Re: [OT] Displaying Time Zones for user preferences
Date Thu, 22 Dec 2011 05:30:29 GMT
2011/12/21 Christopher Schultz <>:
> 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?

IIRC when I installed Fedora on my VM recently it displayed a zoomable
map of Earth surface, allowing me to select the town where I live (and
thus the time zone).

I think you cannot omit entries from the list. You can do some dynamic
filtering based on country or continent (that user types in).

The time zone selection is tricky because you select not only current
time shift value, but all previous time shift rules for this
territory.  So if small city was in Area A but in year xx it was
administratively moved to Area B with different time shift rules,  it
makes this small city a separate time zone with its own historical
record. (Maybe I am wrong, but that is what I think it is).

If your application is only concerned with the current time then your
timezone selection might be a bit more simple than that.

Best regards,
Konstantin Kolinko

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

View raw message