String.format("%0"+length+"d", long)说明

length代表的是格式化吼字符串的总长度
d是个占位符,会被arr所替换。
0是在arr转化为字符后,长度达不到length的时候,前面以0 不足。

int a = 3;
String s = String.format("%03d", a);
System.out.println(s);
比如这样,输出结果为:003
原文地址:https://www.cnblogs.com/miaoer/p/6400043.html