Article View: borland.public.jbuilder.java.language
Article #7872Re: Problem with time zones ...
From: Ivo B. Limmen
Date: Thu, 10 May 2001 10:40
Date: Thu, 10 May 2001 10:40
60 lines
3108 bytes
3108 bytes
Use System.currentMilliseconds() to retrieve the UTC code and make a time of
it.
----8<----
long x = System.currentMilliseconds();
x /= 1000;
int sec = (int)x % 60;
x /= 60;
int min = (int)x % 60;
x /= 60;
int hour = (int)x % 24;
----8<----
This gives you the RAW windows internal time...
Ivo
"Edwin G๏ฟฝnthner" <egu@compart.net> wrote in message
news:3afa34d2$1_1@dnews...
>
> Hi John,
>
> >It would help if you would tell us in which way it fails. Does it
> >throw an exception? Print out incorrect results? Crash your hard
> >drive? :o)
>
> First it killed my dog then it screw up my television set ...
>
> No, the only problem is that it print outs incorrect results. ;-)
> Code is quite simple:
>
> Date date = new Date();
> System.out.println(myFormatter.format(date));
>
> On my machine, it gives me the correct time,
> on the other machine, it gives me correct time + one hour.
>
> I assume that Java ignores this one flag ("change according to
> daylight saving times automatically") that you can setup in
> Windows Date settings.
>
> If I switch of this feature on my machine, the Windows clock will
> show me "correct time - one hour". I assume that Java always takes this
> time and adds one hour. Correct for my machine, but not correct
> if you switch off the windows flag and tell your machine the exact time
> (meaning: the user changes the clock if daylight saving time changes -
and not
> the system).
>
> Maybe a table makes it more clear:
>
> actual time windows time (internal) windows
external Java
> my machine 10:00 9:00 9 +
1 -> 10:00 9+1-> 10:00
> customer 10:00 10:00 10 +
0 -> 10:00 10+1 -> 11.00
>
>
Technical Details
Message-ID:
<9ddr89$sg4$1@porthos.nl.uu.net>Path:
arc1-ca.pugleaf.net!newsfeed.google.com!sn-xit-02!supernews.com!attmtf!ip.att.net!usc.edu!news-out.nuthinbutnews.com!propagator!feed2.newsfeeds.com!newsfeeds.com!news-in-austin.nuthinbutnews.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!skynet.be!news1.ebone.net!news.ebone.net!newsfeed2.news.nl.uu.net!sun4nl!reader1.news.nl.uu.net!not-for-mailReferences:
<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 03:43:38 PST Path: arc1-ca.pugleaf.net!newsfeed.google.com!sn-xit-02!supernews.com!attmtf!ip.att.net!usc.edu!news-out.nuthinbutnews.com!propagator!feed2.newsfeeds.com!newsfeeds.com!news-in-austin.nuthinbutnews.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!skynet.be!news1.ebone.net!news.ebone.net!newsfeed2.news.nl.uu.net!sun4nl!reader1.news.nl.uu.net!not-for-mail From: "Ivo B. Limmen" <limmen@furore.nl> Newsgroups: borland.public.jbuilder.java.language Subject: Re: Problem with time zones ... Date: Thu, 10 May 2001 12:40:15 +0200 Organization: UUNET-NL (http://www.nl.uu.net) Lines: 62 Message-ID: <9ddr89$sg4$1@porthos.nl.uu.net> References: <3af7da0f$1_2@dnews> <MPG.1562bdeacce5495b98a1b2@forums.borland.com> <3afa34d2$1_1@dnews> NNTP-Posting-Host: 1cust223.tnt3.rtm1.nl.uu.net X-Trace: porthos.nl.uu.net 989491273 29188 213.116.100.223 (10 May 2001 10:41:13 GMT) X-Complaints-To: abuse@nl.uu.net NNTP-Posting-Date: 10 May 2001 10:41:13 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400