Java Time Elapsed elapsedTimeStamp(long time)

Here you can find the source of elapsedTimeStamp(long time)

Description

put your documentation comment here

License

Open Source License

Parameter

Parameter Description
time a parameter

Declaration

public static String elapsedTimeStamp(long time) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from w  w w. ja  v  a  2 s  .c  om
     * put your documentation comment here
     * @param time
     * @return
     */
    public static String elapsedTimeStamp(long time) {
        StringBuffer sb = new StringBuffer();
        elapsedTimeStampSection(time / 86400000L, "day", sb);
        elapsedTimeStampSection((time % 86400000L) / 3600000L, "hour", sb);
        elapsedTimeStampSection((time % 3600000L) / 1000L, "second", sb);
        return sb.toString();
    }

    /**
     * put your documentation comment here
     * @param n
     * @param label
     * @param sb
     */
    private static void elapsedTimeStampSection(long n, String label, StringBuffer sb) {
        if (n > 0) {
            if (sb.length() > 0)
                sb.append(", ");
            sb.append(n);
            sb.append(' ');
            sb.append(label);
            if (n > 1)
                sb.append('s');
        }
    }
}

Related

  1. elapsedTime(long milli)
  2. elapsedTime(long ms)
  3. elapsedTime(long startTime, long endTime, double units)
  4. elapsedTime(long timeInMs)
  5. elapsedTimeMs(long start)
  6. elapsedTimeStampSection(long n, String label, StringBuffer sb)
  7. elapsedTimeString(long time)