public class Test {
public static void main(String[] args) throws Exception {
System.out.println(secondsToTime(14555));
}
/***
* 把秒转换为时分秒
* @param seconds
* @return
*/
public static String secondsToTime(long seconds) {
long h = 0;
long d = 0;
long s = 0;
long temp = seconds % 3600;
if (seconds > 3600) {
h = seconds / 3600;
if (temp != 0) {
if (temp > 60) {
d = temp / 60;
if (temp % 60 != 0) {
s = temp % 60;
}
} else {
s = temp;
}
}
} else {
d = seconds / 60;
if (seconds % 60 != 0) {
s = seconds % 60;
}
}
return (h < 10 ? "0" + h : h) + ":" + (d < 10 ? "0" + d : d) + ":"
+ (s < 10 ? "0" + s : s);
}
}
把秒转换为时分秒
最新推荐文章于 2024-07-21 03:11:58 发布