I need to go from milliseconds to a tuple of (hour, minutes, seconds, milliseconds) representing the same amount of time. E.g.:
10799999ms = 2h 59m 59s 999ms
milliseconds = x
total = 0
while (milliseconds >= 1000) {
milliseconds = (milliseconds - 1000)
total = total + 1
}
hr = 0
min = 0
while (total >= 60) {
total = total - 60
min = min + 1
if (min >= 60) hr = hr + 1
if (min == 60) min = 0
}
sec = total
This is on groovy, but I thing that this is not problem for you. Method work perfect.