Here you can find the source of zeroPad(final int amount, final String in)
Parameter | Description |
---|---|
amount | pad size |
in | string |
public static String zeroPad(final int amount, final String in)
//package com.java2s; //License from project: Apache License public class Main { /**/*w w w . j a v a2s . c o m*/ * Pad a string out (yes I know apache commons can do this but it's used by * GWT). * * @param amount * pad size * @param in * string * @return padded value. */ public static String zeroPad(final int amount, final String in) { final int left = amount - in.length(); final StringBuilder out = new StringBuilder(); for (int i = 0; i < left; i++) { out.append("0"); } out.append(in); return out.toString(); } }