Here you can find the source of secondsToTime(double seconds)
public static String secondsToTime(double seconds)
//package com.java2s; //License from project: Open Source License import java.text.DecimalFormat; public class Main { public static String secondsToTime(double seconds) { String result;/*from w w w. j a va 2 s . c o m*/ int minutes = (int) (seconds / 60); seconds = seconds % 60; result = new DecimalFormat("#.###").format(seconds) + "s"; if (minutes == 0) { return result; } int hours = minutes / 60; minutes = minutes % 60; result = minutes + "m " + result; if (hours == 0) { return result; } int days = hours / 24; hours = hours % 24; result = hours + "h " + result; if (days == 0) { return result; } return days + "d " + result; } }