format During To HHMMSS - Java java.util

Java examples for java.util:Date Format

Description

format During To HHMMSS

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        long millis = 2;
        System.out.println(formatDuringToHHMMSS(millis));
    }//from   w w w  .  j  a v a  2 s. com

    public static String formatDuringToHHMMSS(long millis) {
        long second = (millis / 1000) % 60;
        long minute = (millis / (1000 * 60)) % 60;
        long hour = (millis / (1000 * 60 * 60)) % 24;
        String time = String.format("%02d:%02d:%02d", hour, minute, second);
        return time;
    }
}

Related Tutorials