zhaoleigege

java时间格式转化(毫秒 to 00:00)

把秒数转换为%d:%02d:%02d 格式

private String stringForTime(int timeSec) {
int totalSeconds = timeSec;
int seconds = totalSeconds % 60;
int minutes = totalSeconds / 60 % 60;
int hours = totalSeconds / 3600;
if (null!=mFormatBuilder){
this.mFormatBuilder.setLength(0);
}
return hours > 0 ? this.mFormatter.format("%d:%02d:%02d", new Object[]{Integer.valueOf(hours), Integer.valueOf(minutes), Integer.valueOf(seconds)}).toString() : this.mFormatter.format("%02d:%02d", new Object[]{Integer.valueOf(minutes), Integer.valueOf(seconds)}).toString();
}

分类:

技术点:

相关文章:

  • 2021-10-01
  • 2021-08-26
  • 2022-12-23
  • 2022-01-03
  • 2022-03-09
  • 2022-12-23
  • 2022-01-15
猜你喜欢
  • 2021-12-18
  • 2021-12-25
  • 2021-12-12
  • 2022-12-23
  • 2022-12-23
  • 2021-12-26
  • 2022-01-09
相关资源
相似解决方案