当前位置:网站首页>Convert the specified seconds to minutes and seconds
Convert the specified seconds to minutes and seconds
2022-07-23 13:10:00 【Withered maple leaf】
1 Tool method
/** * Convert seconds to minutes and seconds 【01:01:01】 * @param second The number of seconds to convert * @return */
public static String secondConvertHourMinSecond(Long second) {
String str = "00:00:00";
if (second == null || second < 0) {
return str;
}
// Get hours
long h = second / 3600;
str = h > 0 ? ((h < 10 ? ("0" + h) : h) + ":") : "00:";
// Get minutes
long m = (second % 3600) / 60;
str += (m < 10 ? ("0" + m) : m) + ":";
// Get seconds left
long s = second % 60;
str += (s < 10 ? ("0" + s) : s);
return str;
}
2 call
public static void main(String[] args) {
System.out.println(secondConvertHourMinSecond(Long.valueOf(3661)));
}
3 result 
explain : If less than an hour , Hours will also be returned , Minutes will be returned in less than a minute , in other words : The final format is anyway Minutes and seconds The format of
边栏推荐
猜你喜欢
随机推荐
用户与组的管理、文件的权限
雷达导论PART VII.2 成像方法
TI单芯片毫米波雷达xWR1642硬件架构研究
Numpy:基本操作快速入门
OpenVPN deployment
Query the cross compiled executable dependency Library
Outlook 教程,如何在 Outlook 中切换日历视图、创建会议?
How does redis implement persistence? Explain in detail the three triggering mechanisms of RDB and their advantages and disadvantages, and take you to quickly master RDB
2020-09-20
信号完整性(SI)电源完整性(PI)学习笔记(三十二)电源分配网路(四)
查询交叉编译出的可执行文件依赖库
ACL访问控制实验
[offline voice topic ④] Anxin VC offline voice development board secondary development voice control LED light
基于redis+lua进行限流
Hcia---03 ENSP usage, DHCP, router
OSPF single area configuration instance learning record
在GPU上运行MATLAB程序
踩坑electron渲染进程renderer,解决require is not defined的问题
OpenCV图像处理(中) 图像平滑+直方图
北汇信息12岁啦|Happy Birthday








