当前位置:网站首页>将指定秒转为时分秒格式
将指定秒转为时分秒格式
2022-07-23 05:48:00 【枯枫叶】
1 工具方法
/** * 将秒转为时分秒格式【01:01:01】 * @param second 需要转化的秒数 * @return */
public static String secondConvertHourMinSecond(Long second) {
String str = "00:00:00";
if (second == null || second < 0) {
return str;
}
// 得到小时
long h = second / 3600;
str = h > 0 ? ((h < 10 ? ("0" + h) : h) + ":") : "00:";
// 得到分钟
long m = (second % 3600) / 60;
str += (m < 10 ? ("0" + m) : m) + ":";
//得到剩余秒
long s = second % 60;
str += (s < 10 ? ("0" + s) : s);
return str;
}
2 调用
public static void main(String[] args) {
System.out.println(secondConvertHourMinSecond(Long.valueOf(3661)));
}
3 结果
说明:如果不足一小时,也会返回小时,不足一分钟也会返回分钟,也就是说:最后的格式不管怎么样都是时分秒的格式
边栏推荐
- Matplotlib-实现常见概率分布
- Unity3d: script execution sequence on scene loading gameobejct
- 【无标题】
- 课程设计-推箱子C#(win form)
- C#随机生成一个分数,判断其成绩等级(优、良、中、差、不及格)
- Pod 拓扑约束
- Gameframework: resource hot code analysis, check version information, download version files, verify version files, get the number of updated files, download files, taskpool
- User and group management, file permissions
- HCIA----05 RIP
- Secret key remote login server to realize secret free login
猜你喜欢

VLAN的划分以及通过DHCP给所有主机自动分配IP,以及通信全网可达

Pod 拓扑约束

Hcia---03 ENSP usage, DHCP, router

静态路由的搭建

Solution rapide: xshell ne peut pas glisser dans un dossier ou un paquet

HCIA----02

SAR成像之点目标仿真(三)—— 仿真结果分析

Unity3d HD rendering pipeline cannot play video on the model

Unity3d: vector calculation, AOE graph intersection

Gameframework: package resources, publish packages with the app, package and generate folder instructions, upload resources to the server, download resources, gamefreamworklist DAT and gameframeworkve
随机推荐
2020-09-20
App compilation and packaging deployment manual
RHCSA--文件內容瀏覽、cut、uniq、sort、.tr命令使用
HCIA----07 ACL-Net
录入数学公式至mark down文档的方法
Jenkins deployment
[untitled]
0 double pointer leetcode844. Compare strings with backspace
Unity3d HD rendering pipeline cannot play video on the model
ACL access control experiment
es常见操作
TI单芯片毫米波雷达1642代码走读(〇)——总纲
DHCP 配置实例学习记录
Matplotlib-实现常见概率分布
TI单芯片毫米波雷达代码走读(二十五)—— 角度维(3D)处理流程
Write a test case where the executable depends on.So
Hcip --- condition matching and OSPF Protocol
Summary of basic SQL operations
Learning diary - (routing and switching technology) single arm routing
Sword finger offer summary