Java Utililty Methods Integer Pad Zero

List of utility methods to do Integer Pad Zero

Description

The list of methods to do Integer Pad Zero are organized into topic(s).

Method

byte[]zeroPadArray(byte[] source, int size)
Pad a byte array with zeroes.
byte[] data = new byte[size];
for (int i = 0; i < data.length; i++) {
    if (i < source.length)
        data[i] = source[i];
    else
        data[i] = 0;
return data;
...
StringZeroPadded(Integer i)
Zero Padded
String result = "" + i;
if (i < 10)
    result = "0" + result;
return result;
StringzeroPaddedHex(int n, int length)
zero Padded Hex
return padLeft(Integer.toHexString(n), length, '0');
StringzeroPaddedInt(int num, int length)
zero Padded Int
String val = String.valueOf(num);
while (val.length() < length) {
    val = "0" + val;
return val;
StringzeroPadInteger(int i)
zero Pad Integer
return padTo(Integer.toString(i), MAX_INT_CHAR_WIDTH, '0');