public String getOrderNumber() { String orderNumber = ""; String currentDate = DateUtil.getCurrentDate(); Condition condition=new Condition(TbDutyInspectClass.class); condition.createCriteria().andCondition("is_delete=0 ").andCondition("to_char(CREATE_DATE,'yyyy-MM-dd')='" + currentDate + "'"); condition.setOrderByClause("id desc"); List<TbDutyInspectClass> list = mapper.selectByExample(condition); if(list.isEmpty()){ orderNumber = currentDate.replaceAll("-","") + "01"; }else { orderNumber = currentDate.replaceAll("-","") + (list.size()+1); } return orderNumber; }怎么将自增数补成两位数
时间: 2024-02-17 09:59:44 浏览: 119
可以使用 String.format() 方法将自增数格式化成两位数的字符串,例如:
```
orderNumber = currentDate.replaceAll("-","") + String.format("%02d", list.size()+1);
```
这里使用了 %02d,表示格式化为两位数的十进制整数,不足两位时前面补0。
阅读全文