编号的后6位是固定的6位数,新增一条自动+1,高位补0的实现

来源:互联网 发布:株洲中车 知乎 编辑:程序博客网 时间:2024/06/10 05:03

项目中遇到一个业务情况,编号递增且是6位整数。代码自动生成,具体的实现方法如下:
public static String maxRuleCode(String code) {
String maxcode = “”;
if(code == null){
maxcode = “QRC000001”;
} else {
int parseInt = Integer.parseInt(code.substring(3, 9)) + 1;
maxcode =”QRC” + String.format(“%6d”, parseInt).replace(” “, “0”);
}
return maxcode;
}

阅读全文
0 0
原创粉丝点击