本文主要是介绍自动生成合同编号:年月日+流水号自增,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
自动生成合同编号:年月日+流水号自增
/*** 获取合同编号* 合同序号生成规则为:年+月+日+顺序号(自动排序)2022+09+07+01** @return*/public String selectSerialNumber() {int number = 1;SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");String date = sdf.format(new Date()); // 格式化日期 date: 20210114String count = contractMapper.selectSerialNumberMAX(date + "%"); //数据库查询查询最大合同序号后四位+1if (count != null && count.trim() != "") {number = number + Integer.parseInt(count);}DecimalFormat dft = new DecimalFormat("0000");String code = dft.format(number); // 格式化为四位流水号 code: 0001return date + code;}
样例:
这篇关于自动生成合同编号:年月日+流水号自增的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!