Android String Pad from Left lpad(String str, int length)

Here you can find the source of lpad(String str, int length)

Description

lpad

Declaration

public static String lpad(String str, int length) 

Method Source Code

//package com.java2s;

public class Main {
    public static String lpad(String str, int length) {
        if (isBlank(str))
            return "";
        int j = str.length();
        for (int i = j; i < length; i++) {
            str = "0" + str;
        }/*from   w w w  .  j a v  a 2 s .  co  m*/
        return str;
    }

    public static boolean isBlank(String str) {
        if (null == str)
            return true;
        if ("".equals(str.trim()))
            return true;

        return false;
    }

    public static boolean isBlank(Long str) {
        if (null == str)
            return true;
        return false;
    }
}

Related

  1. padding(int width)
  2. padLeft(String input, int size)
  3. prefixPad(String toPad, String padLetter, int targetLength)