How do you format a number of milliseconds into hours, minutes, & seconds? Example, if I have a time of 67149 milliseconds, how can I change that into 1 min 7 secs??
Printable View
How do you format a number of milliseconds into hours, minutes, & seconds? Example, if I have a time of 67149 milliseconds, how can I change that into 1 min 7 secs??
I think you can do it like this. I tried to format from currentTimeMillis(); but i was having trouble. I just woke up and i need my daily caffeine fix. :p
import java.util.Date;
import java.text.DateFormat;
class Timer{
public static void main(String[] args){
// returns the current time in milliseconds since midnight GMT
// January 1,1970 GMT
//long end = System.currentTimeMillis();
DateFormat longTime = DateFormat.getTimeInstance(DateFormat.LONG);
String time = longTime.format(new Date());
System.out.println(time);
}
}