现在的位置: 首页 > 综合 > 正文

把秒换算成时分秒

2017年11月17日 ⁄ 综合 ⁄ 共 253字 ⁄ 字号 评论关闭

public static String cal(int second) {
		int h = 0;
		int d = 0;
		int s = 0;
		int temp = second % 3600;
		if (second > 3600) {
			h = second / 3600;
			if (temp != 0) {
				if (temp > 60) {
					d = temp / 60;
					if (temp % 60 != 0) {
						s = temp % 60;
					}
				} else {
					s = temp;
				}
			}
		} else {
			d = second / 60;
			if (second % 60 != 0) {
				s = second % 60;
			}
		}
		return h + "时" + d + "分" + s + "秒";
	}

抱歉!评论已关闭.