Here you can find the source of formatTime(double totalTime)
public static String formatTime(double totalTime)
//package com.java2s; //License from project: Apache License public class Main { public static String formatTime(double totalTime) { if (totalTime > 60) { double mins = totalTime / 60; int secs = (int) totalTime % 60; if (mins > 60) { int hors = (int) (mins / 60); mins = mins % 60;/*from w w w. ja v a 2 s . c om*/ int m = (int) mins; if (secs == 0) { if (m == 0) { return Integer.toString(hors) + "h"; } else { return Integer.toString(hors) + "h" + Integer.toString(m) + "m"; } } else { if (m == 0) { return Integer.toString(hors) + "h" + Integer.toString(secs) + "s"; } else { return Integer.toString(hors) + "h" + Integer.toString(m) + "m" + Integer.toString(secs) + "s"; } } } else { int m = (int) mins; if (secs == 0) { return Integer.toString(m) + "m"; } else { return Integer.toString(m) + "m" + Integer.toString(secs) + "s"; } } } else { int t = (int) totalTime; return Integer.toString(t) + "s"; } } }