900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > 时间秒转换成时分秒

时间秒转换成时分秒

时间:2021-11-07 21:27:42

相关推荐

时间秒转换成时分秒

时间秒转换成时分秒

1.数据库可以把时间差变成秒

语句为

SELECT//把时间差变成秒, TIMESTAMPDIFF(参数1,开始时间,结束时间)//参数1:DAY(天),HOUR(小时),MINUTE(分钟),SECOND(秒)SELECT TIMESTAMPDIFF(SECOND,'-11-26 15:55:28','-11-26 16:09:22');结果:834秒

2.java转换秒工具类

参数:Integer seconds(传入需要转换成小时分钟秒的数值)public String getTime(Integer seconds){Integer temp=0;StringBuffer time=new StringBuffer();temp = seconds/3600;time.append((temp<10)?temp+"小时":temp+"小时");temp=seconds%3600/60;time.append((temp<10)?temp+"分钟":temp+"分钟");temp=seconds%3600%60;time.append((temp<10)?temp+"秒":temp+"秒");return time.toString();}结果:0小时13分钟54秒

以上就可以把秒换算成时分秒格式

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。