您的位置:首页 > 编程语言 > Java开发

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

2016-09-21 12:01 447 查看
把秒数转换为%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();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: