Java Integer Format formatIntoHHMMSS(int secsIn)

Here you can find the source of formatIntoHHMMSS(int secsIn)

Description

format Into HHMMSS

License

Open Source License

Declaration

public static String formatIntoHHMMSS(int secsIn) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String formatIntoHHMMSS(int secsIn) {

        int hours = secsIn / 3600, remainder = secsIn % 3600, minutes = remainder / 60, seconds = remainder % 60;

        return ((hours < 10 ? "0" : "") + hours + ":" + (minutes < 10 ? "0" : "") + minutes + ":"
                + (seconds < 10 ? "0" : "") + seconds);

    }/*from   w  w  w  . java  2s .  c  o m*/

    public static String formatIntoHHMMSS(long secsIn) {

        long hours = secsIn / 3600, remainder = secsIn % 3600, minutes = remainder / 60, seconds = remainder % 60;

        return ((hours < 10 ? "0" : "") + hours + ":" + (minutes < 10 ? "0" : "") + minutes + ":"
                + (seconds < 10 ? "0" : "") + seconds);

    }
}

Related

  1. formatInteger(Integer value)
  2. formatIntegerBase2WithLeadingZeros(long x, int length)
  3. formatIntegerWithLeadingZeros(long x, int radix, int length)
  4. formatIntents(String[] intents)
  5. formatInterval(long interval)
  6. formatIntoHHMMSS(long l)
  7. formatIntOrLong(long v)
  8. formatInts(int[] vals)
  9. formatIntWithPadding(int value, int length, char pad)