java中整数前进行'0'填充

java中整数前进行'0'填充:

DecimalFormat df=new DecimalFormat("0000");
Integer last = categories.size() + 1;
System.out.println("流水号:"+df.format(last));
code = first + "-" + df.format(last);
System.out.println("分类编号:"+ code);

效果:

 

posted @ 2022-08-11 14:27  changlinlo  阅读(639)  评论(0编辑  收藏  举报