Here you can find the source of humanReadableDateDiff(long start, long end)
public static String humanReadableDateDiff(long start, long end)
//package com.java2s; //License from project: Apache License public class Main { public static String humanReadableDateDiff(long start, long end) { long diff = end - start; StringBuilder sb = new StringBuilder(); long days = diff / (24 * 60 * 60 * 1000); diff -= days * 24 * 60 * 60 * 1000; if (days >= 1) { sb.append(days);/*w w w. j a va2 s . c o m*/ sb.append("d"); } long hours = diff / (60 * 60 * 1000); diff -= hours * 60 * 60 * 1000; if (hours >= 1) { if (sb.length() > 1) { sb.append(' '); } sb.append(hours); sb.append("h"); } if (sb.length() > 1) { sb.append(' '); } long minutes = diff / (60 * 1000); diff -= minutes * 60 * 1000; sb.append(minutes); sb.append("m "); sb.append(Math.round(Math.ceil(diff / 1000.0))); sb.append("s"); return sb.toString(); } }