Wednesday, 26 May 2021

Convert millisecond to time in Android Studio in Java


Therefore 1 second = 1 seconds. 1 millisecond = (0.001 seconds / 1 secondsseconds. 0 seconds makes a millisecond.

Here is simple coding to convert millisecond to convert Hours:Minutes:Second in java.

How to convert millisecond to time in java

long mSecond = millisecond;
long mSecondToHours=mSecond/3600000;
long mSecondToHoursByMinute=mSecond%3600000;
long mSecondToSecond= mSecondToHoursByMinute/1000;
long secondToMinute=mSecondToSecond/60;
long secondToMinuteBySecond=mSecondToSecond%60;
String time=(
" "+mSecondToHours+"H : "+secondToMinute+"M : "+secondToMinuteBySecond+"S");
Replace red marked millisecond char to required numbers or a variable.

No comments:

Post a Comment