Java Millisecond Convert getHumanDisplayForTimediff(Long diffMillis)

Here you can find the source of getHumanDisplayForTimediff(Long diffMillis)

Description

get Human Display For Timediff

License

Open Source License

Declaration

public static String getHumanDisplayForTimediff(Long diffMillis) 

Method Source Code


//package com.java2s;
import java.text.DecimalFormat;

public class Main {
    public static String getHumanDisplayForTimediff(Long diffMillis) {
        if (diffMillis == null) {
            return "";
        }/* ww w. j  a  va2s.com*/
        long day = diffMillis / (24 * 60 * 60 * 1000);
        long hour = (diffMillis / (60 * 60 * 1000) - day * 24);
        long min = ((diffMillis / (60 * 1000)) - day * 24 * 60 - hour * 60);
        long se = (diffMillis / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60);
        StringBuilder sb = new StringBuilder();
        if (day > 0) {
            sb.append(day + "D");
        }
        DecimalFormat df = new DecimalFormat("00");
        sb.append(df.format(hour) + ":");
        sb.append(df.format(min) + ":");
        sb.append(df.format(se));
        return sb.toString();
    }
}

Related

  1. convertToMillis(String time)
  2. convertToMilliseconds(String value)
  3. getDuration(final long millis)
  4. getDurationBreakdown(long durationInMillis)
  5. getDurationMillisecond(Date date1, Date date2)
  6. getNice(long timeMillisecGMT)
  7. getStringFromMillis(long timestamp)
  8. getTime(long millis)
  9. getTime(long time, boolean withMilliseconds)