//startLetter为订单号前缀
public static String create(String startLetter, int size, int numSize) {
String orderNo = null;
Date nowDate = new Date();
Random random = new Random();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
//生成两位大写字母
String keyArr = randomLetter(size);
String fourRandom = random.nextInt(9999) + "";
int randLength = fourRandom.length();
//numSize 位随机数,不足 numSize 位的补0
if (fourRandom.length() < numSize) {
for (int i = 1; i <= numSize - randLength; i++) {
fourRandom = '0' + fourRandom;
}
}
orderNo = startLetter + keyArr + sdf.format(nowDate) + fourRandom;
return orderNo;
}
最后
以上就是美满大米最近收集整理的关于根据时间与自定义前缀生成生产流水号的全部内容,更多相关根据时间与自定义前缀生成生产流水号内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复