首页 > 编程语言 > 详细

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

时间:2016-09-21 13:04:51      阅读:459      评论:0      收藏:0      [点我收藏+]
把秒数转换为%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();
}

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

原文:http://www.cnblogs.com/zhaoleigege/p/5892150.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!