Re: Time zone problem moving from JDK 1.4 to 1.5
From: Thomas Weidenfeller (nobody_at_ericsson.invalid)
Date: 01/26/05
- Next message: Antti S. Brax: "Re: URL and Url?"
- Previous message: Tony Morris: "Re: URL and Url?"
- In reply to: Wendy S: "Time zone problem moving from JDK 1.4 to 1.5"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 26 Jan 2005 11:06:16 +0100
Wendy S wrote:
> On HP-UX, we've always used 'MST7' for our timezone, and we've had no
> problems until a recent move to JDK 1.5. Suddenly, all the Tomcat logs and
> the webapps thought they were in GMT.
>
> Did something officially change in the format that Java wants for timezones?
> Or was 'MST7' always wrong, and it just now decided to bite us? The server
> admin claims that MST7 is valid, and 'date' continues to return the correct
> date and time at the prompt.
Take the following with a gain of salt, because time zone abbreviations
are a mess. E.g. it would have helped if you would have told us where
you are, because in some areas on the globe MST is Moscow Summer Time
... And the second problem is the non-intuitive way of Unix TZ
specifications.
Java 1.5. has apparently giving up on interpreting TZ the same twisted
way than Unix does. For example, in Unix your TZ=MST7 does not refers to
a predefined timezone, instead it is a specification (TZ=:MST7 would
have been a reference to a predefined timezone, but there is no such
date predefined). With TZ=MST7 you specify that you want to get your
time displayed with a 7 hour offset from GMT and a designation of "MST".
But with TZ=MST (better would be TZ=:MST) you refers to a predefined
timezone, which happens to have the same seven hour offset, so by some
luck you get the same time displayed.
Java 1.5 apparently doesn't do this any more. It just looks up the TZ
string in its own time zone database. If it can find the name it uses
the corresponding time zone information. If it can't find the name, it
falls back to GMT. The date display you got is correct. Just that is is
not in the desired time zone. Whether this change of interpreting TZ is
a bug or feature I don't know. Maybe you have some luck checking the
release notes and the bugparade.
A check of Java's zone info map reveals that it knows about MST and
MST7MDT, but not MST7. In general I would however recommend to use zone
names like ":US/Mountain" or ":America/Denver" or whatever and let the
system fetch the matching abbreviation from its database - if it knows
it. If not, it will fall back to GMT.
/Thomas
-- The comp.lang.java.gui FAQ: ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
- Next message: Antti S. Brax: "Re: URL and Url?"
- Previous message: Tony Morris: "Re: URL and Url?"
- In reply to: Wendy S: "Time zone problem moving from JDK 1.4 to 1.5"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|