Here you can find the source of humanTime(long seconds)
public static String humanTime(long seconds)
//package com.java2s; //License from project: Open Source License public class Main { public static String humanTime(long seconds) { long diff[] = new long[] { 0, 0, 0, 0 }; /* sec */diff[3] = (seconds >= 60 ? seconds % 60 : seconds); /* min */diff[2] = (seconds = (seconds / 60)) >= 60 ? seconds % 60 : seconds; /* hours */diff[1] = (seconds = (seconds / 60)) >= 24 ? seconds % 24 : seconds; /* days */diff[0] = (seconds = (seconds / 24)); /*/*from w ww . j a va 2 s.c o m*/ String text = ""; if (diff[0] > 1) text += "%d d%s"; if (diff[1] > 1) text += "%d h%s"; if (diff[1] > 1) text += "%d m%s"; if (diff[1] > 1) text += "%d s%s"; */ String text = String.format( //"%d hour%s, %d minute%s, %d second%s", "%d days %02d:%02d:%02d", diff[0], //diff[0] > 1 ? "s" : "", diff[1], //diff[1] > 1 ? "s" : "", diff[2], //diff[2] > 1 ? "s" : "", diff[3] //diff[3] > 1 ? "s" : "" ); return text; } }