Here you can find the source of formatIntWithPadding(int value, int length, char pad)
Parameter | Description |
---|---|
value | a parameter |
length | a parameter |
pad | a parameter |
public static final String formatIntWithPadding(int value, int length, char pad)
//package com.java2s; //License from project: Apache License public class Main { /**/*from ww w.j av a2s. co m*/ * * @param value * @param length * @param pad * @return */ public static final String formatIntWithPadding(int value, int length, char pad) { String valueStr = value + ""; int diff = length - valueStr.length(); StringBuilder strBuilder = new StringBuilder(); if (diff > 0) { while (diff > 0) { diff--; strBuilder.append(pad); } strBuilder.append(valueStr); valueStr = strBuilder.toString(); } return valueStr; } }