I want my time to be formated like: 03:04.9 (example)
This is what I have right now:
fun formatTime(data: Long): String {
val seconds = ((data / 1000.0) % 60.0)
val minutes = (TimeUnit.MILLISECONDS.toMinutes(data) % 60).toInt()
return String.format(Locale.US, "%02d:%.1f", minutes, seconds)
}
It kind of works but doesn't make sure that the seconds value has two digits. This is how the output looks like when the seconds are under 10: 03:4.9
I think I'm so close but just can't get it right