Here you can find the source of zeroPrefix(String str, int width)
public static String zeroPrefix(String str, int width)
//package com.java2s; //License from project: Open Source License public class Main { public static String zeroPrefix(String str, int width) { return prefix(str, '0', width); }//from w w w.j av a 2s . com public static String zeroPrefix(long l, int width) { return prefix(String.valueOf(l), '0', width); } public static String prefix(String str, char prefix, int width) { StringBuffer ret = new StringBuffer(str); while (ret.length() < width) ret.insert(0, prefix); return ret.toString(); } }