format Duration in second - Java java.util

Java examples for java.util:Second

Description

format Duration in second

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        long seconds = 2;
        System.out.println(formatDuration(seconds));
    }/*from  ww  w.  java  2 s.  co m*/

    public static String formatDuration(long seconds) {
        return String.format("%02d:%02d:%02d", seconds / 3600,
                (seconds % 3600) / 60, (seconds % 60));
    }
}

Related Tutorials