package com.sifang.modules.quality.utils;

import com.sifang.modules.sys.common.utils.DateUtils;

import java.util.Date;

public class NumberGenUtil {


    public static String gen(String prefix, Date date, long seq) {
        return gen(prefix, date, seq, 5);
    }

    public static String gen(String prefix, Date date, long seq, Integer seqWidthLimit) {
        String format = "%0d";
        if (seqWidthLimit != null) {
            assert seqWidthLimit > 0;
            format = "%0" + seqWidthLimit + "d";
        }
        return prefix + DateUtils.formatDate(date, "yyyyMMdd") + String.format(format, seq);
    }

    public static String genYmdhmm(String prefix, Date date, long seq, Integer seqWidthLimit) {
        String format = "%0d";
        if (seqWidthLimit != null) {
            assert seqWidthLimit > 0;
            format = "%0" + seqWidthLimit + "d";
        }
        return prefix + DateUtils.formatDate(date, "yyMMddHHmmss") + String.format(format, seq);
    }
    public static void main(String[] args) {
        System.out.println(genYmdhmm("",new Date(),1,3));
    }
}
