time zone
Hi,
I am working on project that allow the user choose the timezone and then manage the datatime according to their preference.
First of all where can I get a sound list of timezone data? I searched http://forum.java.sun.com/thread.jspa?forumID=256&threadID=374499 Also there are a lot timezone database, for example http://www.twinsun.com/tz/tz-link.htm which way is better? JVM or database? I am looking at JVM one in the post, I can get the list of ID, displayName, is getRawOffset for GMT offset? how can I get DST rules? DoesJVM has historical rules? How can I know when I need to add vs. minus an hour? I might populate the data in our database for consistency. I looked at PST there are 8
America/DawsonPacific Standard Time-8 1
America/Los_AngelesPacific Standard Time-8 1
America/VancouverPacific Standard Time-8 1
Canada/PacificPacific Standard Time-8 1
PSTPacific Standard Time-8 1
SystemV/PST8PDTPacific Standard Time-8 1
US/Pacific-NewPacific Standard Time-8 1
If I put all 8 in the list, is the user going to get confused?
[1115 byte] By [
jennyhua] at [2007-11-27 8:54:43]

> How> can I know when I need to add vs. minus an hour?You shouldn't need to know. Using the right TZ should take care of that for you.
jverda at 2007-7-12 21:14:30 >

Thanks. If some country decided to change their DST rule, it won't be reflected in JVM. How can I deal with that? Do I list store the DST rule?
> Thanks. If some country decided to change their DST
> rule, it won't be reflected in JVM. How can I deal
> with that? Do I list store the DST rule?
Sun updates the time zone information stored in the jre when it releases new versions/updates. If you want to have current tz info for your locale, you need to keep your jre up to date. You can check the release notes for the specific version of the jre to see how up to date it's tz info is.
I need the recommendation to get the time zone data list so that the user can choose from the list. The jre I am using has 567. That's just too many. Thanks
I think you'll just have to hard code a select list of time zones.
> I need the recommendation to get the time zone data
> list so that the user can choose from the list. The
> jre I am using has 567. That's just too many. Thanks
There's probably only around 24 or so of them you'd need to list, assuming the rest of the world follows the same scheme as the US. As I understand it, new time zones don't get created or removed very often, it's the time offsets that change. So if they choose GMT +1, they'll pretty much always be in that zone, you just need to calculate that zone's offset based on current rules.
> I need the recommendation to get the time zone data> list so that the user can choose from the list. The> jre I am using has 567. That's just too many. ThanksAre you Canadian?
> There's probably only around 24 or so of them you'd
> need to list, assuming the rest of the world follows
> the same scheme as the US. As I understand it, new
> time zones don't get created or removed very often,
> it's the time offsets that change. So if they choose
> GMT +1, they'll pretty much always be in that zone,
> you just need to calculate that zone's offset based
> on current rules.
How can I pick 24 out of 576? I don't get what you mean by saying "assuming the rest of the world follows the same scheme as the US".
BTW I am in America/LosAngeles.
> How can I pick 24 out of 576?
Take a look at the Forum Profile and Settings page, and their time zone
drop down list:
http://forum.java.sun.com/settings!default.jspa
They have quite a few time zones, but less than 500! Why not use their choices?
That's how you pick some...
> I don't get what you
> mean by saying "assuming the rest of the world
> follows the same scheme as the US".
I was going to use Canada as a counter example to the USA scheme.
Canada's Newfoundland Time Zone is *a half hour* ahead of the Atlantic
Time Zone. And then Saskatchewan does not recognise Daylight Savings Time,
except around Lloydminster. So 24 time zones is not enough.
> BTW I am in America/LosAngeles.
Okay. I am Canada/Pacific. I guess we're in the same time zone. Sorta.
Well, according to the US Naval Observatory in 2004, there are ~30 or so different time zones that correspond roughly to the 24 hours in a day. You can do more research to see if there are others that they don't list, but I'd be satisfied with those to choose from.
http://aa.usno.navy.mil/faq/docs/world_tzones.html
(the png and pdf versions are nice and huge)
That's a good map (P* was my Newfie example) but it throws its hands up on DST. Not only do some regions not observe it, but the starting and ending dates will vary.
I got the one in the Settings. It has 75 items. I think I need the rule to filter to make sure I have everything that I need but not extra. The list in the Settings take account DST and I think the list changes between DST begin/end. For example: (GMT-7:00) Pacific Time (US & Canada); Tijuana for zoneID America/Los_Angeles has "GMT-7:00". Is this the good way to present to user? Also the list items are kind of hand crafted meaning it's not zone DisplayName or anything.
Thanks
> That's a good map (P* was my Newfie example) but it
> throws its hands up on DST. Not only do some regions
> not observe it, but the starting and ending dates
> will vary.
Right, but that's independent of the location of the time zone. The OP's asking about how to provide the user with a list to choose from. Once you know where the user lives, then you apply the current offset, based of when that timezone's dst starts/ends, if they observe it, etc. You don't need to know anything about dst to pick which one you live in.