/**
* 里数字转字符串前面自动补0的实现。
*
*/
public class TestStringFormat {
public static void main(String[] args) {
int youNumber = 1;
// 0 代表前面补充0
// 4 代表长度为4
// d 代表参数为正数型
String str = String.format("%04d", youNumber);
System.out.println(str); // 0001
}
}
Java数字格式化输出时前面补0
猜你喜欢
转载自blog.csdn.net/machihaoyu/article/details/78836493
今日推荐
周排行