Here you can find the source of secondsToHoursMinutesSeconds(final long secs)
Parameter | Description |
---|---|
secs | The number of seconds. |
public static String secondsToHoursMinutesSeconds(final long secs)
//package com.java2s; //License from project: Open Source License public class Main { /**//w w w . j av a2 s.co m * Converts seconds into hours:minutes:seconds. * * @param secs The number of seconds. * @return The formatted string. */ public static String secondsToHoursMinutesSeconds(final long secs) { final double minutesRemaining = (secs / 60) % 60; final double hoursRemaining = Math.floor(secs / 60 / 60); final double secondsRemaining = secs % 60; final StringBuilder sb = new StringBuilder(); if (hoursRemaining > 0.0) { sb.append((int) hoursRemaining); sb.append(" hrs, "); } if (minutesRemaining > 0.0) { sb.append((int) minutesRemaining); sb.append(" mins, "); } sb.append((int) secondsRemaining); sb.append(" secs"); return sb.toString(); } }