Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio Kotlin - How to display 2 digit number in text?

On creating a timer In Android Studio Kotlin.

I'd like to display the time value as it's 2 digit number like '01:04:07'.

Please see the below.

enter image description here

enter image description here

At this point, how do I change the code?

like image 672
JUNS Avatar asked Dec 13 '22 08:12

JUNS


1 Answers

Simply use String.format() like:

timerDisplay.text = String.format("%02d:%02d:%02d", lapsHours, lapsMinutes, lapsSeconds)
like image 55
aminography Avatar answered Dec 17 '22 23:12

aminography