Here you can find the source of formatSeconds(double seconds)
public static String formatSeconds(double seconds)
//package com.java2s; //License from project: Open Source License public class Main { public static String formatSeconds(double seconds) { /*//w w w .j a v a 2 s. c om return formatDuration(Duration.ofSeconds((long) seconds, Math.round((seconds - (int) seconds) * 10) * 100000000L));// , // 1); */ int i = (int) seconds; int s = i % 60; int m = i / 60; int min = m % 60; int h = m / 60; return (h > 0 ? fillZeros(h, 2) + ":" : "") + (m > 0 || h > 0 ? fillZeros(min, 2) + ":" : "") + fillZeros(s, 2) + "." + (seconds % 1 != 0 ? String.valueOf(seconds % 1).substring(2, 3) : "0"); } private static String fillZeros(int number, int amount) { String s = ""; if (number == 0) { for (int i = 0; i < amount - 1; i++) { s += "0"; } } else { for (int i = number; i < Math.pow(10, amount - 1); i *= 10) { s += "0"; } } return s + number; } }