Java Integer Pad Zero ZeroPad(int number, int width)

Here you can find the source of ZeroPad(int number, int width)

Description

Zero Pad

License

Open Source License

Declaration

public static String ZeroPad(int number, int width) 

Method Source Code

//package com.java2s;

public class Main {
    public static String ZeroPad(int number, int width) {
        StringBuffer result = new StringBuffer("");
        for (int i = 0; i < width - Integer.toString(number).length(); i++)
            result.append("0");
        result.append(Integer.toString(number));

        return result.toString();
    }/*from  www.j  a  va2 s.  com*/
}

Related

  1. zeropad(final int num, final int size)
  2. zeroPad(int i, int len)
  3. zeroPad(int n, int base, int width)
  4. zeroPad(int n, int len)
  5. zeroPad(int number, int places)
  6. zeroPad(int value, int padding)
  7. zeroPadArray(byte[] source, int size)
  8. ZeroPadded(Integer i)
  9. zeroPaddedHex(int n, int length)