0

i want to format date and time with given number like

val time = 4
val hour = 5 

how to write it like that 4:05

String.format("%d:%d", time.hours, time.minutes)
Daniil Pavlenko
  • 153
  • 1
  • 9
Ahsan Ali
  • 171
  • 1
  • 12

1 Answers1

1

use this format:

  String.format("%02d:%02d",time.hours ,time.minutes)

use %02d instead of %d

Bhoomika Patel
  • 1,895
  • 1
  • 13
  • 30