Java 生成每次加1的系统编号

/**
 * @author  sunli
 * @date 2020/8/12
 * @deprecated 生成系统编号
 **/
public class BHUtils {
        /**
         * 生成规则系统编号:类型+四位编号(从1开始,不够前补0)
         * @param equipmentType
         *              类型
         * @param equipmentNo
         *              设备编号
         * @return 拼接完成的系统编号
         */
        public static String getNewEquipmentNo(String equipmentType, String equipmentNo){
            String newEquipmentNo = "0001";

            if(equipmentNo != null && !equipmentNo.isEmpty()){
                int newEquipment = Integer.parseInt(equipmentNo) + 1;
//                                                            关键是看生成几位的系统编号
//                newEquipmentNo = String.format(equipmentType + "%05d", newEquipment);
                newEquipmentNo = String.format(equipmentType + "%04d", newEquipment);
            }
            return  newEquipmentNo;
        }

        public static void main(String[] args) {
            String equipmentNo = BHUtils.getNewEquipmentNo("14000-", "0035");
            System.out.println("生成系统编号:" + equipmentNo);
        }

}

你可能感兴趣的:(笔记,java)