For a nice string representation, using the TimeUnit lib:
String.format("%02d:%02d",
TimeUnit.MILLISECONDS.toMinutes(milliSeconds),
TimeUnit.MILLISECONDS.toSeconds(milliSeconds) -
TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(milliSeconds)));
Javaor simply do the math:
int minutes = (int) (milliSeconds/ 1000) / 60;
int seconds = (int) (milliSeconds/ 1000) % 60;
Javaand back to miliseconds again:
long milliSeconds= ((minutes * 60) + seconds) * 1000;
Java
Leave a Reply