// 设置初始化值为5 private static AtomicInteger count = new AtomicInteger(5);
// 生成发票流水号的8位年月日与4位序列号 private static String issueInvoiceSerival(){ Timestamp curDate = new Timestamp(System.currentTimeMillis()); String[] str = curDate.toString().split(" ")[0].split("-"); String dateTemp = str[0] + str[1] + str [2]; return dateTemp + String.format("%04d", count.incrementAndGet()); } // Java之四位序列号生成方式 String.format("%04d", count.incrementAndGet());