Here you can find the source of formatNumber(String formatStr, int length, boolean leftPadding, char paddingCharacter)
public static String formatNumber(String formatStr, int length, boolean leftPadding, char paddingCharacter)
//package com.java2s; //License from project: Apache License public class Main { public static String formatNumber(String formatStr, int length, boolean leftPadding, char paddingCharacter) { StringBuilder result = new StringBuilder(formatStr); String paddingStr = String.valueOf(paddingCharacter); while (result.length() < length) { if (leftPadding) { result = (new StringBuilder(paddingStr)).append(result); } else { result.append(paddingCharacter); }/*from ww w.ja va 2 s . c o m*/ } return result.toString(); } }