Here you can find the source of toMillisToHHMMSSTime(long timeMillis)
Parameter | Description |
---|---|
timeMillis | a parameter |
public static String toMillisToHHMMSSTime(long timeMillis)
//package com.java2s; //License from project: Apache License public class Main { /**// ww w .j a v a 2 s.c o m * convert to hh:mm:ss * * @param timeMillis * @return */ public static String toMillisToHHMMSSTime(long timeMillis) { String timeString = ""; timeMillis = timeMillis / 1000; int days = (int) (timeMillis / 60 / 60 / 24); if (days > 0) { if (days < 10) { timeString += "0" + days + "-"; } else { timeString += days + "-"; } } int dayTime = days * 24 * 60 * 60; int hours = (int) ((timeMillis - dayTime) / 60 / 60); if (hours < 10) { timeString += "0" + hours + ":"; } else { timeString += hours + ":"; } int minutes = (int) ((timeMillis - dayTime - hours * 60 * 60) / 60); if (minutes < 10) { timeString += "0" + minutes + ":"; } else { timeString += minutes + ":"; } int seconds = (int) (timeMillis % 60); if (seconds < 10) { timeString += "0" + seconds; } else { timeString += seconds; } return timeString; } }