Here you can find the source of formatTimeDuration(long timeDuration)
public static String formatTimeDuration(long timeDuration)
//package com.java2s; //License from project: Apache License public class Main { public static String formatTimeDuration(long timeDuration) { StringBuilder builder = new StringBuilder(); long hours = timeDuration / (60 * 60 * 1000); long mod = (timeDuration % (60 * 60 * 1000)); long minutes = mod / (60 * 1000); mod = mod % (60 * 1000);/* w ww . ja v a 2s . c o m*/ long seconds = mod / 1000; mod = mod % 1000; long ms = mod; if (hours != 0) { builder.append(hours); builder.append(" hrs, "); } if (minutes != 0) { builder.append(minutes); builder.append(" mins, "); } if (seconds != 0) { builder.append(seconds); builder.append(" sec, "); } builder.append(ms); builder.append(" ms"); return builder.toString(); } }