java 秒转换时间,不足一分钟按一分钟算
/**
* @param second 秒
* @description: 秒转换为时分秒 HH小时mm分钟格式 ss秒大于0时不足一分钟,按一分钟算
* @return: {@link String}
* @author:
* @date: 2022-05-08 13:55:17
*/
public static String secondToStrTime(Long second) {
if (second == null || second < 0) {
return "0分钟";
}
long h = second / 3600;
long m = (second % 3600) / 60;
long s = second % 60;
if(s > 0){
second += 60 - s;
return secondToStrTime(second);
}
String str = "";
if (h > 0) {
str = h + "小时";
}
if(m > 0){
str += m + "分钟";
}
if(StringUtils.isEmpty(str)){
return "0分钟";
}else{
return str;
}
}