This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes Subtract two timeperiods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Subtract two timeperiods" Watch "Subtract two timeperiods" New topic
Author

Subtract two timeperiods

sandy kailash
Greenhorn

Joined: Feb 23, 2010
Posts: 9
hi friends,

I want to subtract two timeperiods say 04:46:30 from 02:30:22 and also the reverse should give the true result...

i want the result in milliseconds or in hh:mm:ss

Is there any java function for this.

and also function to convert the value from millseconds to hh:mm:ss.

thanks in advance..
Carey Brown
Ranch Hand

Joined: Nov 19, 2001
Posts: 174

Here's code that converts a begin ms and end ms into a duration string:

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38426
    
  23
That actually looks an awkward way to do it. There is a far better way, but that would only give a clean result with a positive difference.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Subtract two timeperiods