Paula Wellera

Greenhorn
+ Follow
since Jan 08, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Paula Wellera

Some funny examples:
--------------------
Code:
-----
System.out.println("local time: "+ new Date(System.currentTimeMillis()));
GregorianCalendar calendar = new GregorianCalendar();
calendar.setTimeInMillis(0);
System.out.println("local calendar time: "+ calendar.getTime());
System.out.println("GMT calendar time: "+ calendar.getTime().toGMTString());

Output when in GMT timezone:
----------------------------
local time: Fri Jan 09 19:05:43 GMT 2004
local calendar time: Thu Jan 01 01:00:00 GMT 1970
GMT calendar time: 1 Jan 1970 00:00:00 GMT

Output when in CET timezone (GMT+1)
-----------------------------------
local time: Fri Jan 09 20:06:15 CET 2004
local calendar time: Thu Jan 01 01:00:00 CET 1970
GMT calendar time: 1 Jan 1970 00:00:00 GMT

Code:
-----
long ONE_DAY = 24*60*60*1000;
for (int i=0; i<3000; i++) {
calendar.setTimeInMillis(i * ONE_DAY);
System.out.println("local calendar time: "+ calendar.getTime());
}
Output:
-------
local calendar time: Thu Jan 01 01:00:00 GMT 1970
local calendar time: Fri Jan 02 01:00:00 GMT 1970
local calendar time: Sat Jan 03 01:00:00 GMT 1970
local calendar time: Sun Jan 04 01:00:00 GMT 1970 any time but not GMT
local calendar time: Mon Jan 05 01:00:00 GMT 1970
local calendar time: Tue Jan 06 01:00:00 GMT 1970
local calendar time: Wed Jan 07 01:00:00 GMT 1970
local calendar time: Thu Jan 08 01:00:00 GMT 1970
...
...
local calendar time: Wed Oct 27 01:00:00 GMT 1971
local calendar time: Thu Oct 28 01:00:00 GMT 1971
local calendar time: Fri Oct 29 01:00:00 GMT 1971
local calendar time: Sat Oct 30 01:00:00 GMT 1971
local calendar time: Sun Oct 31 01:00:00 GMT 1971 suddenly it's right
local calendar time: Mon Nov 01 00:00:00 GMT 1971
local calendar time: Tue Nov 02 00:00:00 GMT 1971
local calendar time: Wed Nov 03 00:00:00 GMT 1971
...
...
local calendar time: Thu Mar 16 00:00:00 GMT 1972
local calendar time: Fri Mar 17 00:00:00 GMT 1972
local calendar time: Sat Mar 18 00:00:00 GMT 1972
local calendar time: Sun Mar 19 00:00:00 GMT 1972
local calendar time: Mon Mar 20 01:00:00 BST 1972 brasilian show time ?? british summer time ??
local calendar time: Tue Mar 21 01:00:00 BST 1972
local calendar time: Wed Mar 22 01:00:00 BST 1972
local calendar time: Thu Mar 23 01:00:00 BST 1972

What this means is that most of the years 70 and 71 (how long before 70) there was a time difference to GMT in the GMT's own country. Is that right and if so why?
Anyway, imho naming this GMT is not correct. So one has to be careful with Date.
Any ideas ;-)
Paula
[ January 09, 2004: Message edited by: Paula Wellera ]
17 years ago
Hello again,
Well Ko Ko, I'm sitting in germany ;-) .It took me 2 hours to find the reason. It's not the timezone setting on my machine as you suggest. When I posted the message I was already playing with different timezones around the world. Always the same result.
The reason is the TimeZone implementation "GMT" aka "Europe/London".
Even if you are in GMT you get different results for
Date.toString() // Thu Jan 01 01:00:00 GMT 1970
and
Date.toGMTString() // Thu Jan 01 00:00:00 GMT 1970 (depr.)
The 1st of january is definitely not in any daylightsavingtime (as TimeZone.inDaylightTime(Date date) shows. Despite this fact the toString() method still shows 01:00:00. May be it is some strange british use/behaviour/history I don't know. When it shows GMT it should be GMT and this implementation doesn't.
Thanks for your posts folks,
Best regards,
Paula
[ January 09, 2004: Message edited by: Paula Wellera ]
17 years ago
Hy folks,
I'm somewhat confused, hope somebody can answer my question.
Why do I get this result:
Code:
-----
GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(0);
Date testdate = calendar.getTime();
System.out.println(testdate +" millis: "+ testdate.getTime());
Output:
-------
Thu Jan 01 01:00:00 GMT 1970 millis: 0

Shouldn't I get "Thu Jan 01 00:00:00 GMT 1970" ???
What's going on here? Sure, I'm in GMT.
Thanks for any idea in advance,
emmzettel
17 years ago