Here you can find the source of secondsToStringWithUnits(double value)
public static String secondsToStringWithUnits(double value)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); you may public class Main { private final static long MINUTE = 60; private final static long HOUR = MINUTE * 60; private final static long DAY = HOUR * 24; private final static long WEEK = DAY * 7; public static String secondsToStringWithUnits(double value) { String result = value > 0 ? "" : "0 secs"; double secondsRemaining = value; if (secondsRemaining > WEEK) { long numUnits = (long) (secondsRemaining / WEEK); secondsRemaining = secondsRemaining % WEEK; result += numUnits;/*from www . j a v a2 s . c om*/ result += numUnits > 1 ? " wks " : " wk "; } if (secondsRemaining > DAY) { long numUnits = (long) (secondsRemaining / DAY); secondsRemaining = secondsRemaining % DAY; result += numUnits; result += numUnits > 1 ? " days " : " day "; } if (secondsRemaining > HOUR) { long numUnits = (long) (secondsRemaining / HOUR); secondsRemaining = secondsRemaining % HOUR; result += numUnits; result += numUnits > 1 ? " hrs " : " hr "; } if (secondsRemaining > MINUTE) { long numUnits = (long) (secondsRemaining / MINUTE); secondsRemaining = secondsRemaining % MINUTE; result += numUnits; result += numUnits > 1 ? " mins " : " min "; } if (secondsRemaining > 0) { result += (long) secondsRemaining; result += secondsRemaining > 1 ? " secs" : " sec"; } return result; } }