使用SimpleDateFormat 将毫秒转换成时分秒 格式:HH:mm:ss

public static String dateFormatFromMilliSecond(long seconds) {
		// 初始化format格式
		SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");

		// 设置时区,跳过此步骤会默认设置为"GMT+08:00" 得到的结果会多出来8个小时
		dateFormat.setTimeZone(TimeZone.getTimeZone("GMT+00:00"));

		String time = dateFormat.format(seconds);

		return time;
	}

例如,输入2000的话,输出结果: 00:00:02

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章