Here you can find the source of formatSeconds(int seconds)
public static String formatSeconds(int seconds)
//package com.java2s; import java.util.concurrent.TimeUnit; public class Main { public static String formatSeconds(int seconds) { int millis = seconds * 1000; long min = TimeUnit.MILLISECONDS.toMinutes(millis); long sec = TimeUnit.MILLISECONDS.toSeconds(millis) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)); if ((int) sec == 0 && min > 0) { if ((int) min == 1) { return min + " minute"; } else { return min + " minutes"; }/*ww w . j av a 2 s . com*/ } else if ((int) min == 0) { if ((int) sec == 1) { return sec + " second"; } else { return sec + " seconds"; } } return String.format("%d minute(s) and %d second(s)", min, sec); } }