Here you can find the source of lpad(String str, int length)
public static String lpad(String str, int length)
//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; } }