Here you can find the source of zeroFormattedStr(int number, int length)
public static String zeroFormattedStr(int number, int length)
//package com.java2s; //License from project: Apache License public class Main { public static String zeroFormattedStr(int number, int length) { return zeroFormattedStr((long) number, length); }// ww w . j a va 2 s . c om public static String zeroFormattedStr(long number, int length) { String numberStr = String.valueOf(number); int size = numberStr.length(); int additionZeros = length - size; if (additionZeros > 0) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < additionZeros; i++) { sb.append('0'); } sb.append(numberStr); numberStr = sb.toString(); } return numberStr; } }