Here you can find the source of convertSecondsToHoursMinutesSeconds(int offset)
Parameter | Description |
---|---|
offset | the offset to be converted |
static public String convertSecondsToHoursMinutesSeconds(int offset)
//package com.java2s; //License from project: Apache License public class Main { /**/* w w w. jav a 2s . c om*/ * Converts a second offset into a * friendlier hh:mm:ss format & returns the string. If time is less than one * hour, returns mm:ss only. * * @param offset the offset to be converted * @return the String representation of the time value */ static public String convertSecondsToHoursMinutesSeconds(int offset) { int seconds = offset; int minutes = seconds / 60; int hours = minutes / 60; String strSeconds = new String(); String strMinutes = new String(); seconds = seconds - (minutes * 60); minutes = minutes - (hours * 60); if (seconds < 10) { strSeconds = "0" + seconds; } else { strSeconds = "" + seconds; } if ((minutes < 10) && (hours > 0)) { strMinutes = "0" + minutes; } else { strMinutes = "" + minutes; } if (hours > 0) { return (hours + ":" + strMinutes + ":" + strSeconds); } else { return (strMinutes + ":" + strSeconds); } } }