Here you can find the source of formatTimeSpanSeconds(long span)
public static String formatTimeSpanSeconds(long span)
//package com.java2s; //License from project: Open Source License public class Main { public static String formatTimeSpanSeconds(long span) { final int minute = 60; final int hour = 60 * 60; final int day = 24 * hour; if (span < minute) { return span + "s"; } else if (span < hour) { return (span / 60) + "m " + (span % 60) + "s"; } else if (span < day) { span = span / 60;/* w w w. j a v a 2 s . c om*/ return (span / 60) + "h " + (span % 60) + "m"; } else { long days = span / day; long hours = (span % day) / hour; long minutes = (span % hour) / minute; return days + "d " + hours + "h " + minutes + "m"; } } }