| Author |
10000 milliseconds showing as 01:00:10.000 - why ?
|
Pascal Got
Greenhorn
Joined: Mar 05, 2002
Posts: 23
|
|
Hi, I have a problem with the following code... I take the time as "now", add 10 seconds and want to display the difference between the two. I am expecting to see 00:00:10.000 but I get 01:00:10.000... why ? The output is : 10000 milliseconds is 10 seconds right ? so should be January 1st 1970 00:00:10.000 right ? but it's formatted as 01:00:10.000 All i want is display the difference between 2 dates ... any other way ? Why ? oh why ? Thanks Pascal
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16487
|
|
Here's a hint: when I replaced "Europe/London" by "America/Vancouver" the output was this: Wed Dec 31 16:00:10 PST 1969 diff: 10000 diff: 04:00:10.000 PST diff: 4:00:10 PM Any other way to display the difference between two dates? Well, yes, any other way would be preferable. You already have 10,000 milliseconds. Just use ordinary arithmetic to get the number of seconds.
|
 |
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
|
|
Contrary to what you might think, Europe/London doesn't actually use Greenwich Mean Time. Not during this part of the year, anyway. If you want GMT, ask for TimeZone.getTimeZone("GMT") instead. See here for a similar discussion, and a solution that avoids using Date and DateFormat entirely, instead using simple math as Paul suggests. [ October 02, 2007: Message edited by: Jim Yingst ]
|
"I'm not back." - Bill Harding, Twister
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16487
|
|
Originally posted by Jim Yingst: Contrary to what you might think, Europe/London doesn't actually use Greenwich Mean Time. Not during this part of the year, anyway. If you want GMT, ask for TimeZone.getTimeZone("GMT") instead.
The actual difference is that Britain was using daylight saving time on January 1, 1970!
|
 |
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
|
|
|
Good point. Were they calling it British Summer Time back then? The mind boggles.
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16487
|
|
|
Yes, they were.
|
 |
 |
|
|
subject: 10000 milliseconds showing as 01:00:10.000 - why ?
|
|
|