如何使用字符串格式 class 将零添加到格式时间?
how to add Zero to Format Time using String Format class?
我想用给定的数字格式化日期和时间,例如
val time = 4
val hour = 5
怎么写啊4:05
String.format("%d:%d", time.hours, time.minutes)
使用这种格式:
String.format("%02d:%02d",time.hours ,time.minutes)
使用%02d
代替%d
我想用给定的数字格式化日期和时间,例如
val time = 4
val hour = 5
怎么写啊4:05
String.format("%d:%d", time.hours, time.minutes)
使用这种格式:
String.format("%02d:%02d",time.hours ,time.minutes)
使用%02d
代替%d