Here you can find the source of formatNumberImpl(long i, int digits, String fill)
public static String formatNumberImpl(long i, int digits, String fill)
//package com.java2s; public class Main { public static String formatNumberImpl(long i, int digits, String fill) { int ten = 10; String res = ""; while (digits > 1) { if (i < ten) { res += fill;/*from w w w. j av a 2s . c o m*/ } digits--; ten *= 10; } return res + String.valueOf(i); } }