Java Zero Format zeroFillString(String originalString, int numZeros)

Here you can find the source of zeroFillString(String originalString, int numZeros)

Description

zero Fill String

License

Open Source License

Declaration

public static String zeroFillString(String originalString, int numZeros) 

Method Source Code

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

public class Main {
    private static final int BTOL_NUM_ZEROS = 4;

    public static String zeroFillString(String originalString, int numZeros) {
        if (originalString.length() < numZeros) {
            int zerosToAdd = numZeros - originalString.length();
            for (int i = 0; i < zerosToAdd; i++) {
                originalString = "0" + originalString;
            }//  ww  w.ja v  a 2 s .  co  m
        }
        return originalString;
    }

    public static String zeroFillString(String originalString) {
        return zeroFillString(originalString, BTOL_NUM_ZEROS);
    }
}

Related

  1. zeroFill(float[] array)
  2. zeroFill(int iv, int len)
  3. zeroFill(int num, int size, String character)
  4. zeroFill(int value, int fieldWidth)
  5. zerofill(int x, int desiredWidth)
  6. zeroFormat(Integer source)
  7. zeroFormattedStr(int number, int length)
  8. zeroIfNull(Integer i)
  9. zeroIfNull(Integer i)