发票流水号生成方式

// 设置初始化值为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());

 

AtomicInteger类的理解与使用 【http://www.javashuo.com/article/p-xsjpwcux-cq.html
相关文章
相关标签/搜索