Here you can find the source of getReadableTimeUsage(long timeUsageMs)
Parameter | Description |
---|---|
timeUsageMs | a parameter |
public static String getReadableTimeUsage(long timeUsageMs)
//package com.java2s; //License from project: Apache License public class Main { /**/* ww w.j a v a2 s. c o m*/ * Format the time usage to string like "1d17h37m3s728ms" * @param timeUsageMs * @return */ public static String getReadableTimeUsage(long timeUsageMs) { long millisecondsLeft = timeUsageMs % 1000; if (timeUsageMs == millisecondsLeft) { return millisecondsLeft + "ms"; } long seconds = timeUsageMs / 1000; long secondsLeft = seconds % 60; if (secondsLeft == seconds) { return secondsLeft + "s" + millisecondsLeft + "ms"; } long minutes = seconds / 60; long minutesLeft = minutes % 60; if (minutesLeft == minutes) { return minutesLeft + "m" + secondsLeft + "s" + millisecondsLeft + "ms"; } long hours = minutes / 60; long hoursLeft = hours % 24; if (hoursLeft == hours) { return hoursLeft + "h" + minutesLeft + "m" + secondsLeft + "s" + millisecondsLeft + "ms"; } long days = hours / 24; return days + "d" + hoursLeft + "h" + minutesLeft + "m" + secondsLeft + "s" + millisecondsLeft + "ms"; } }