From owner-freebsd-java Tue Feb 12 22: 3:53 2002 Delivered-To: freebsd-java@freebsd.org Received: from conn.mc.mpls.visi.com (conn.mc.mpls.visi.com [208.42.156.2]) by hub.freebsd.org (Postfix) with ESMTP id 8F1AB37B405 for ; Tue, 12 Feb 2002 22:03:49 -0800 (PST) Received: from [209.98.155.26] (envy.blackcore.com [209.98.155.26]) by conn.mc.mpls.visi.com (Postfix) with ESMTP id CF802811F for ; Wed, 13 Feb 2002 00:03:48 -0600 (CST) User-Agent: Microsoft-Entourage/10.0.0.1331 Date: Wed, 13 Feb 2002 00:03:47 -0600 Subject: Re: Incorrect timestamps with native 1.3.1 jdk? From: Timothy Kettering To: Message-ID: In-Reply-To: <20020213171140.A8612@grimoire.chen.org.nz> Mime-version: 1.0 Content-type: text/plain; charset="US-ASCII" 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 I tried that same test below. The results came out identical for me as well, so java is indeed returning the correct unix timestamp. I also did some further digging around after I posted my initial email, and heres what I found out. I modified the program that Jonathan Chen posted to also do a format using SimpleDateFormat.. Code follows: import java.util.Date; import java.text.*; public class DateTest { static void main (String args []) { Date now = new Date (); SimpleDateFormat formatter = new SimpleDateFormat("zzz"); System.out.println ("Now = " + (now.getTime () / 1000)); System.out.println("timezone is: " + formatter.format(now)); } } I get the following result: /javafiles > java DateTest Now = 1013579034 timezone is: GMT+06:00 However, if I type in "date" at the same terminal: /javafiles > date Tue Feb 12 23:49:56 CST 2002 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 -- Tim Kettering http://www.blackcore.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message