不够位数的在前面补0

/**
     * desc: 不够位数的在前面补0,保留num的长度位数字
     * date: 2021/9/10 10:03
     * @author gl
     * @param code 
     * @param num 
     * @return {@link String}
    */
    private String autoGenericCode(String code, int num) {
        // 保留num的位数
        // 0 代表前面补充0
        // num 代表长度为4
        // d 代表参数为正数型
        return String.format("%0" + num + "d", Integer.parseInt(code) + 1);
    }
随笔看心情
原文地址:https://www.cnblogs.com/stromgao/p/15250163.html