Here you can find the source of intToFixedLengthString(int value, int length)
Parameter | Description |
---|---|
value | integer value to be converted |
length | length of the output string |
public static String intToFixedLengthString(int value, int length)
//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); } }