Here you can find the source of secondsToETA(long secondsTotal)
public static String secondsToETA(long secondsTotal)
//package com.java2s; //License from project: Open Source License import java.util.concurrent.TimeUnit; public class Main { public static String secondsToETA(long secondsTotal) { long hours = TimeUnit.SECONDS.toHours(secondsTotal); long minutes = TimeUnit.SECONDS.toMinutes(secondsTotal) - TimeUnit.HOURS.toMinutes(TimeUnit.SECONDS.toHours(secondsTotal)); long seconds = secondsTotal - TimeUnit.MINUTES.toSeconds(TimeUnit.SECONDS.toMinutes(secondsTotal)); String str;// w ww .j ava 2s. co m if (hours > 0) { str = String.format("%02d:%02d:%02ds", hours, minutes, seconds); } else if (minutes > 0) { str = String.format("%02d:%02ds", minutes, seconds); } else { str = String.format("%02ds", seconds); } return str; } }