aspose file tools
The moose likes Beginning Java and the fly likes Time.toString() format Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Time.toString() format" Watch "Time.toString() format" New topic
Author

Time.toString() format

Paul Hennessey
Greenhorn

Joined: Jul 23, 2005
Posts: 15
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
Tom Henner
Greenhorn

Joined: Jul 04, 2005
Posts: 18
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

Joined: Jul 23, 2005
Posts: 15
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
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Time.toString() format
 
Similar Threads
Where does the extra day come from in duration calculation?
Unix OS on Windows Vista ?
Total Time duration
Compare time (time difference in java)
DateTime Problem