Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Feb 2002 09:34:33 +0100
From:      Erwan Arzur <earzur@noos.fr>
To:        Timothy Kettering <timster@blackcore.com>
Cc:        freebsd-java@freebsd.org
Subject:   Re: Incorrect timestamps with native 1.3.1 jdk?
Message-ID:  <3C6A2519.2030401@noos.fr>
References:  <B88F5DE3.4EB1%timster@blackcore.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Timothy Kettering wrote:
> 
> As far as I can see, there's a problem here.  CST is -600 GMT, not +600 GMT.
> This would very well explain why I'm getting 12 hour differences when
> formatting my Date objects.
> 
> So what I'm wondering is - am I supposed to set some sort of system variable
> for java to use, or was java supposed to automatically pick up this timezone
> information from my server and its gone slightly screwy?
> 
> -tim
> 
> 

Just read the sources of java.util.Date / java.util.TimeZone, and you'll 
see as i did how much date and timezones handling sucks in the java 
standard library.

What happens is that the OS timezone names and java's one are different, 
thus you *have* to specify it on the command line. This is to keep it 
"portable across different architecture" (what they did not assert is 
that any decent OS should provide means to keep programs independent 
from timezones !)

As i'm currently working in France, every single application i write 
must set the user.timezone system property to "ECT" (while the OS thinks 
appropriately MET or CET) in order to display correct times.

I remember posting a bug about that four years ago, and someone in Sun 
replied me it was normal TimeZone handling, and not a tipycal "everyone 
should use CST and a QWERTY keyboard" behaviour ;-)

And read the source :

in src/java/util/TimeZone.java

         new SimpleTimeZone(-6*ONE_HOUR, "America/Regina" /*CST*/),
         // America/Regina   Saskatchewan(CA)    -6:00   -   CST
         //----------------------------------------------------------

So when you use, CST, java thinks you're in the America/Regina time 
zone. :-)

And this comment speaks for itself :

         // The following data is current as of 1998.
         // Total Unix zones: 343
         // Total Java zones: 289
         // Not all Unix zones become Java zones due to duplication and 
overlap.


Find the appropriate timezone in this file, and use

/path/to/java -Duser.timezone="MYTZ"

this will solve your problem ...


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-java" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3C6A2519.2030401>