Here you can find the source of formatTime(long time)
public static String formatTime(long time)
//package com.java2s; //License from project: Open Source License public class Main { public static String formatTime(long time) { StringBuilder ret = new StringBuilder(); int days = (int) Math.floor(time / (1000 * 3600 * 24)); int hours = (int) Math.floor((time % (1000 * 3600 * 24)) / (1000 * 3600)); int minutes = (int) Math.floor((time % (1000 * 3600 * 24)) % (1000 * 3600) / (1000 * 60)); int seconds = (int) Math.floor(time % (1000 * 3600 * 24) % (1000 * 3600) % (1000 * 60) / 1000); if (days != 0) ret.append(days + "d"); if (hours != 0 || days != 0) ret.append(hours + "h"); if (minutes != 0 || hours != 0 || days != 0) ret.append(minutes + "m"); ret.append(seconds + "s"); return ret.toString(); }/* w w w. j a v a 2s . c o m*/ }