Here you can find the source of formatTime(long timeDiffMillis)
public static String formatTime(long timeDiffMillis)
//package com.java2s; //License from project: Apache License public class Main { public static String formatTime(long timeDiffMillis) { StringBuilder buf = new StringBuilder(); long hours = timeDiffMillis / (60 * 60 * 1000); long rem = (timeDiffMillis % (60 * 60 * 1000)); long minutes = rem / (60 * 1000); rem = rem % (60 * 1000);/*from w w w . j a v a 2s . com*/ long seconds = rem / 1000; if (hours != 0) { buf.append(hours); buf.append("h"); } if (hours != 0 || minutes != 0) { if (buf.length() > 0) { buf.append(" "); } buf.append(minutes); buf.append("m"); } if (buf.length() > 0) { buf.append(" "); } buf.append(seconds).append("s"); return buf.toString(); } }