• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Time.toString() format

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I hope this isn't just because I'm too tired to think straight any more but here goes:

My app logs events, and timestamps them with a long integer. In order to work out the interval between two events I'm trying to subtract one from the other and output the difference, like this:



By my calculations, that comes to around 11 seconds. But instead of getting 00:00:11, I get 01:00:11.

Can anyone explain why this is happening?

Thanks,

Paul
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul- I don't have access to Time to test- but could it be the locale is the problem? If you pass in the start and end values they do seem 11 seconds apart. Maybe try passing those into Time and printing.
 
Paul Hennessey
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the suggestion Tom. I think I know whats happening now.

The Time class is a 24 hour clock that starts at 01:00:00. So if you create a Time object and initialise it with 0, you get 01:00:00. If you create a Time object and initialise it with 3600000 (one hour in milliseconds), you get 02:00:00, etc.

This means that this class is no use to me, as it wraps round after 24 hours. Guess I'll just have to do some work and write my own formatting code <sigh>.

Paul
 
It's fun to be me, and still legal in 9 states! Wanna see my tiny ad?
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic