码迷,mamicode.com
首页 > 编程语言 > 详细

JAVA将秒的总和转换成时分秒的格式

时间:2016-09-13 20:47:20      阅读:426      评论:0      收藏:0      [点我收藏+]

标签:

public static void main(String[] args) {
String str = "221";
int seconds = Integer.parseInt(str);
int temp=0;
StringBuffer sb=new StringBuffer();
temp = seconds/3600;
sb.append((temp<10)?"0"+temp+":":""+temp+":");

temp=seconds%3600/60;
sb.append((temp<10)?"0"+temp+":":""+temp+":");

temp=seconds%3600%60;
sb.append((temp<10)?"0"+temp:""+temp);

System.out.println(sb.toString());

}

 

JAVA将秒的总和转换成时分秒的格式

标签:

原文地址:http://www.cnblogs.com/wllcs/p/5869502.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!