• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

10000 milliseconds showing as 01:00:10.000 - why ?

 
Pascal Got
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good point. Were they calling it British Summer Time back then? The mind boggles.
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, they were.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic