Skip to content

Instantly share code, notes, and snippets.

@binjoo
Created October 21, 2012 08:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save binjoo/3926302 to your computer and use it in GitHub Desktop.
Save binjoo/3926302 to your computer and use it in GitHub Desktop.
JAVA:补齐不足长度
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