Article View: borland.public.jbuilder.java.language
Article #7889Re: Problem with time zones ...
From: John McGrath TeamB
Date: Fri, 11 May 2001 03:40
Date: Fri, 11 May 2001 03:40
46 lines
2551 bytes
2551 bytes
On 9 May 2001 23:27:30 -0700, Edwin G๏ฟฝnthner wrote:
> On my machine, it gives me the correct time,
> on the other machine, it gives me correct time + one hour.
It sounds like the time configuration on the other machine is somehow
screwed up. Java date/time values work correctly for me on all of the
machines I work with.
> I assume that Java ignores this one flag ("change according to
> daylight saving times automatically") that you can setup in
> Windows Date settings.
There really should not be any change in the time values when daylight
savings time (or summer time) kicks in. Java stores time values using
an offset in milliseconds since the beginning of the "epoch", which I
believe was 1-Jan-1970, 0:00:00 UT. When daylight savings time is in
effect, the values should be formatted differently, but the actual
values do not change.
Try running this program on the different machines and post the
results. That should give some idea what is wrong.
import java.util.Date;
import java.text.DateFormat;
public class Time {
public static void main( String[] args ) {
Date date = new Date();
DateFormat format = DateFormat.getDateTimeInstance(
DateFormat.FULL, DateFormat.FULL );
System.out.println( date.getTime() + " = "
+ format.format( date ) );
}
}
BTW, what operating system(s) are you running this on?
--
Regards,
John McGrath [TeamB]
---------------------------------------------------
Before sending me e-mail, please read:
http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID:
<MPG.156424c7a806f3d698a1c5@forums.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.sj.google.com!news2.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!206.252.192.28!news.stealth.net!nntp1.njy.teleglobe.net!teleglobe.net!hub.org!hub.org!PeerFeed.KWeb.on.ca!dnewsReferences:
<3af7da0f$1_2@dnews> <MPG.1562bdeacce5495b98a1b2@forums.borland.com> <3afa34d2$1_1@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: f74b3,a59c8cd977ce05a X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-05-10 20:45:49 PST From: John McGrath [TeamB] <ng-b@JPMcGrath.net> Newsgroups: borland.public.jbuilder.java.language Subject: Re: Problem with time zones ... Date: Thu, 10 May 2001 23:40:26 -0400 Message-ID: <MPG.156424c7a806f3d698a1c5@forums.borland.com> References: <3af7da0f$1_2@dnews> <MPG.1562bdeacce5495b98a1b2@forums.borland.com> <3afa34d2$1_1@dnews> X-Newsreader: MicroPlanet Gravity v2.30 NNTP-Posting-Host: 209.92.40.60 X-Trace: dnews 989552425 209.92.40.60 (10 May 2001 20:40:25 -0700) Lines: 46 X-Authenticated-User: jpmcgrath Path: arc1-ca.pugleaf.net!archiver1.sj.google.com!news2.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!206.252.192.28!news.stealth.net!nntp1.njy.teleglobe.net!teleglobe.net!hub.org!hub.org!PeerFeed.KWeb.on.ca!dnews