https://kotlinlang.org logo
#android
Title
# android
j

Jason

02/06/2021, 1:47 AM
Actually, I want to convert seconds Int to
mm:ss
such as : 300 seconds ->
05:00
a

Akash Veerappan

02/06/2021, 2:13 AM
I would simply look into String.format
😉 1
j

Jason

02/06/2021, 2:47 AM
Copy code
fun Int.toMinuteSecond(): Pair<Long, Long> {
    val duration: Duration = Duration.ofSeconds(this.toLong())
    val minutes = duration.toMinutes()
    val seconds = duration.minusMinutes(minutes).seconds
    return minutes to seconds
}
I do as this way
2 Views