Here you can find the source of toSeconds(long millis)
public static String toSeconds(long millis)
//package com.java2s; //License from project: Open Source License public class Main { public static String toSeconds(long millis) { return toString(millis, "s"); }//from ww w .j a va 2s . c om public static String toString(long millis, String unit) { double factor = getFactor(unit); return ((double) millis) / factor + unit; } private static long getFactor(String value) { long factor = 0; if (value.endsWith("ms")) { factor = 1; } else if (value.endsWith("s")) { factor = 1000; } else if (value.endsWith("m")) { factor = 1000 * 60; } else if (value.endsWith("h")) { factor = 1000 * 60 * 60; } else if (value.endsWith("d")) { factor = 1000 * 60 * 60 * 24; } return factor; } }