方法一:使用UUID public static String getUUID() { String replaceUUID = UUID.randomUUID().toString().replace("-", "");
public static String getUUID() { String replaceUUID = UUID.randomUUID().toString().replace("-", ""); return replaceUUID; }
public static synchronized String getOrderNum() { //时间(精确到毫秒) DateTimeFORMatter ofPattern = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS"); String localDate = LocalDateTime.now().format(ofPattern); //3位随机数 String randomNumeric = RandomStringUtils.randomNumeric(3); String orderNum = localDate + randomNumeric; log.info("订单号:{}", orderNum); return orderNum; }
来源地址:https://blog.csdn.net/weixin_52293201/article/details/131438641
--结束END--
本文标题: JAVA生成唯一订单编号方案(两种方式)
本文链接: https://lsjlt.com/news/404922.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-04-01
2024-04-03
2024-04-03
2024-01-21
2024-01-21
2024-01-21
2024-01-21
2023-12-23
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0