*
The moose likes Beginning Java and the fly likes Converting millisecs to hour, minute, seconds. 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 "Converting millisecs to hour, minute, seconds." Watch "Converting millisecs to hour, minute, seconds." New topic
Author

Converting millisecs to hour, minute, seconds.

Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 761

I have an interval of time in milliseconds.
Is there any utility to convert that
to an interval specified in
hour:minute:sec
Thanks
Pho


Regards,

Pho
Jessica Sant
Sheriff

Joined: Oct 17, 2001
Posts: 4313

I think you can use a combination of the java.util.Calendar and java.util.Date
Check out these methods in particular:
void Date.setTime(long time);
and
Date Calendar.getTime();


- Jess
Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
Bob Smith
Greenhorn

Joined: May 17, 2002
Posts: 1
Just divide by 1000, 60 etc.
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
hours = ms / (1000*60*60);
ms = ms % (1000*60*60);
minutes = ms / (1000*60);
ms = ms % (1000*60);
seconds = ms / 1000;


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 761

Thank you all.
Pho.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Converting millisecs to hour, minute, seconds.