-
-
Save DimovskiD/015c55207ea8289edef5ec6ba69b1bc4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun Long.formatTime(): String { | |
val seconds = ((this / 1000).toInt() % 60).doubleDigit() | |
val minutes = ((this / (1000 * 60) % 60).toInt()).doubleDigit() | |
val hours = ((this / (1000 * 60 * 60) % 24).toInt()).doubleDigit() | |
var result = "$hours:$minutes:$seconds" | |
if (result.startsWith("00")) result = result.substring(3) | |
return result | |
} | |
fun Int.doubleDigit(): String = if (this.toString().length == 1) "0$this" | |
else this.toString() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment