Android Second Format formatTime(int second)

Here you can find the source of formatTime(int second)

Description

format Time

Declaration

public static String formatTime(int second) 

Method Source Code

//package com.java2s;

import java.util.Locale;

public class Main {
    public static String formatTime(int second) {

        int hh = second / 3600;
        int mm = second % 3600 / 60;
        int ss = second % 60;

        if (0 != hh) {
            return String
                    .format(Locale.CHINA, "%02d:%02d:%02d", hh, mm, ss);
        } else {/*  w  w w. j a  v  a2s.  c  o m*/
            return String.format(Locale.CHINA, "%02d:%02d", mm, ss);
        }
    }
}

Related

  1. formatTime(int second)
  2. formatIntoHHMMSS(int secsIn)
  3. getTimeFormattedFromSeconds(int seconds)
  4. formatElapsedTime(long elapsedSeconds)