字符串左补零
/**
* 左补位
*
* @param str 字符串
* @param length 总位数
* @return Result 补位后的字符串
*/
public static String addZeroForNum(String str, int length) {
int strLen = str.length();
if (strLen < length) {
while (strLen < length) {
StringBuffer sb = new StringBuffer();
sb.append("0").append(str);
str = sb.toString();
strLen++;
}
}
return str;
}