Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Feb 2002 00:03:47 -0600
From:      Timothy Kettering <timster@blackcore.com>
To:        <freebsd-java@freebsd.org>
Subject:   Re: Incorrect timestamps with native 1.3.1 jdk?
Message-ID:  <B88F5DE3.4EB1%timster@blackcore.com>
In-Reply-To: <20020213171140.A8612@grimoire.chen.org.nz>

next in thread | previous in thread | raw e-mail | index | archive | help

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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?B88F5DE3.4EB1%timster>