Here you can find the source of secondsToTimecode(long seconds)
public static String secondsToTimecode(long seconds)
//package com.java2s; //License from project: Open Source License public class Main { public static String secondsToTimecode(long seconds) { long hours = 0; long mins = 0; long secs = 0; hours = seconds / 3600L;/*www .j a va2 s . com*/ seconds -= (hours * 3600); mins = seconds / 60L; secs = seconds - (mins * 60L); String result = String.format(":%02d", Long.valueOf(secs)); if ((hours > 0L) || (mins > 0L)) { String fmt = (hours > 0L) ? "%02d" : "%d"; result = String.format(fmt + "%s", Long.valueOf(mins), result); } if (hours > 0L) { result = String.format("%d:%s", Long.valueOf(hours), result); } return result; } }