/**
* 将秒数 匹配成 xx时 xx分xx秒
*
* @param time
* @return
*/
public static String secondUpMatch(int time) {
int hour = 0;
int minute = 0;
int second = 0;
if (time <= 0) {
return "";
}
// 不足一分钟 --> xx秒
if (time < 60) {
return time + "秒";
}
minute = time / 60;
// 不足一小时 --> xx分xx秒
if (minute < 60) {
second = time % 60;
return minute + "分" + (second > 0 ? second + "秒" : "");
}
hour = minute / 60;
minute = minute % 60;
second = time - hour * 3600 - minute * 60;
return hour + "时" + (minute > 0 ? minute + "分" : "") + (second > 0 ? second + "秒" : "");
}
将秒数 [整数型] 匹配成 xx时 xx分xx秒
最新推荐文章于 2020-09-21 14:49:33 发布