Created
October 21, 2012 08:17
-
-
Save binjoo/3926302 to your computer and use it in GitHub Desktop.
JAVA:补齐不足长度
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Test { | |
public static void main(String[] args) { | |
Test test = new Test(); | |
System.out.println(test.lpad(10, 23)); | |
} | |
/** | |
* 补齐不足长度 | |
* @param length 长度 | |
* @param number 数字 | |
* @return | |
*/ | |
private String lpad(int length, int number) { | |
String f = "%0" + length + "d"; | |
return String.format(f, number); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment