Here you can find the source of formatSeconds(long seconds)
public static String formatSeconds(long seconds)
//package com.java2s; //License from project: Open Source License public class Main { public static String formatSeconds(long seconds) { long d = seconds / 3600 / 24; long h = (seconds / 3600) % 24; long m = (seconds / 60) % 60; long s = seconds % 60; if (d > 0) return d + "d" + h + "h" + m + "m" + s + "s"; if (h > 0) return h + "h" + m + "m" + s + "s"; if (m > 0) return m + "m" + s + "s"; return s + "s"; }//from w ww . j a va 2s. c o m }