java生成序列为001,有序的编号
方式一
String.format("%04d", num)
方式二
public class Test009 {
public static void main(String[] args) {
String code = sequenceCode(1000, 1);
System.out.println(code);
}
/**
* 生成001的编号
*
* @param maxNum 最大数
* @param count 累计的
* @return
*/
public static String sequenceCode(Integer maxNum, Integer count) {
String strNum = String.valueOf(maxNum + count);
if (StringUtils.isEmpty(strNum) || 1 >= strNum.length()) {
return "";
}
return strNum.substring(1);
}
}