From owner-freebsd-java Wed Feb 13 0:46:20 2002 Delivered-To: freebsd-java@freebsd.org Received: from frmug.org (frmug-gw.frmug.org [193.56.58.252]) by hub.freebsd.org (Postfix) with ESMTP id 6947437B405 for ; Wed, 13 Feb 2002 00:46:16 -0800 (PST) Received: (from uucp@localhost) by frmug.org (8.11.3/8.11.3/frmug-2.7/nospam) with UUCP id g1D8j3o01809; Wed, 13 Feb 2002 09:45:03 +0100 (CET) (envelope-from earzur@noos.fr) Received: from noos.fr (localhost [127.0.0.1]) by amelie.frmug.org (Postfix) with ESMTP id D0212710C; Wed, 13 Feb 2002 09:34:33 +0100 (CET) Message-ID: <3C6A2519.2030401@noos.fr> Date: Wed, 13 Feb 2002 09:34:33 +0100 From: Erwan Arzur User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:0.9.8) Gecko/20020205 X-Accept-Language: en-us MIME-Version: 1.0 To: Timothy Kettering Cc: freebsd-java@freebsd.org Subject: Re: Incorrect timestamps with native 1.3.1 jdk? References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org 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