Java Zero Format zeroFormat(Integer source)

Here you can find the source of zeroFormat(Integer source)

Description

zero Format

License

Open Source License

Declaration

public static String zeroFormat(Integer source) 

Method Source Code

//package com.java2s;

public class Main {
    public static String zeroFormat(Integer source) {
        String stringSource = String.valueOf(source);
        if (stringSource.length() >= 3)
            return source + "";
        return String.format("%03d", source);
    }/*  w  ww .  j  a v a  2 s .c  o m*/

    public static String zeroFormat(Integer source, Integer zeroNum) {
        if (zeroNum == null)
            zeroNum = 0;
        String stringSource = String.valueOf(source);
        if (stringSource.length() >= zeroNum)
            return source + "";
        return String.format("%0" + zeroNum + "d", source);
    }
}

Related

  1. zeroFill(int iv, int len)
  2. zeroFill(int num, int size, String character)
  3. zeroFill(int value, int fieldWidth)
  4. zerofill(int x, int desiredWidth)
  5. zeroFillString(String originalString, int numZeros)
  6. zeroFormattedStr(int number, int length)
  7. zeroIfNull(Integer i)
  8. zeroIfNull(Integer i)
  9. zeroIfNullStrict(Integer i)