Java Time Elapsed elapsedTimeString(long time)

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

Description

elapsed Time String

License

Open Source License

Declaration

public static String elapsedTimeString(long time) 

Method Source Code

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

public class Main {
    public static String elapsedTimeString(long time) {

        final long DAY = 86400000;
        final long HOUR = 3600000;
        final long MIN = 60000;

        long remaintime = time;

        long days = remaintime / DAY;
        remaintime = remaintime - DAY * days;

        long hours = remaintime / HOUR;
        remaintime = remaintime - HOUR * hours;

        long mins = remaintime / MIN;
        remaintime = remaintime - MIN * mins;

        long secs = remaintime / 1000;
        remaintime = remaintime - 1000 * secs;

        String timeString = "" + days + "d:" + hours + "h:" + mins + "m:" + secs + "s:" + remaintime;
        return timeString;

    }/*  ww w.  j a  v a  2 s . c om*/
}

Related

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