首页 > 编程语言 > 详细

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

时间:2016-09-13 20:47:13      阅读:167      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!