Here you can find the source of getTimeInterval(long interval)
Parameter | Description |
---|---|
startDate | Interval start date time |
endDate | Interval end date time |
public static String getTimeInterval(long interval)
//package com.java2s; public class Main { /** /* w ww .ja v a 2 s . c o m*/ * * @param startDate Interval start date time * @param endDate Interval end date time * @return Time interval in format hh:mm:ss */ public static String getTimeInterval(long interval) { if (interval <= 0) { return "00:00:00"; } long intervalSeconds = interval / 1000; long hours = intervalSeconds / 3600; long minutes = (intervalSeconds % 3600) / 60; long seconds = intervalSeconds % 60; String hoursText = String.valueOf(hours); if (hoursText.length() == 1) { hoursText = "0" + hoursText; } String minutesText = String.valueOf(minutes); if (minutesText.length() == 1) { minutesText = "0" + minutesText; } String secondsText = String.valueOf(seconds); if (secondsText.length() == 1) { secondsText = "0" + secondsText; } return hoursText + ":" + minutesText + ":" + secondsText; } }