pad Left with String.format - Android java.lang

Android examples for java.lang:String Pad

Description

pad Left with String.format

Demo Code

import android.content.Context;

public class Main{

    public static String padLeft(Object s, char padChar, int n) {
        return String.format("%1$" + n + "s", s).replace(' ', padChar);
    }//from   w  ww  .  j a  va2 s  . c om

}

Related Tutorials