pad string from left Left - Android java.lang

Android examples for java.lang:String Pad

Description

pad string from left Left

Demo Code

import android.annotation.SuppressLint;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;

public class Main{

    public static String padLeft(String s, int n) {
        return String.format("%1$" + n + "s", s);
    }//from   w  w w  .  ja  v a2  s . c o m

}

Related Tutorials