Java Integer to intToFixedLengthString(int value, int length)

Here you can find the source of intToFixedLengthString(int value, int length)

Description

Converts the given integer to a fixed length string by adding leading zeros to the given number that its length equals to the given length.

License

Open Source License

Parameter

Parameter Description
value integer value to be converted
length length of the output string

Return

string presentation of the given integer

Declaration

public static String intToFixedLengthString(int value, int length) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from   w  w  w  .  j a  v a  2s  .co m*/
     * Converts the given integer to a fixed length string by adding
     * leading zeros to the given number that its length equals to the
     * given length.
     *
     * @param value  integer value to be converted
     * @param length length of the output string
     * @return string presentation of the given integer
     */
    public static String intToFixedLengthString(int value, int length) {
        return String.format("%0" + length + "d", value);
    }
}

Related

  1. intToEightHexString(final int value)
  2. intToEle(int integEle)
  3. intToEncodedID(int input)
  4. IntToEnode62(Integer int10)
  5. IntToEnode62(Integer int10)
  6. intToFourByte(long value, byte[] dest, int off)
  7. intToFourBytes(int i)
  8. intToFourBytes(int iValue, byte b[], int offset)
  9. intToFourChars(int value)