公司需要开发商城项目,用到了,记录一下
Java订单号生成唯一
package com.iot.store.utils;
import org.apache.commons.lang3.RandomStringUtils;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
public class OrderIDGenerator {
public static String getOrderNumber() {
String time = DateTimeFormatter.ofPattern("yyyyMMddHHmmss").format(LocalDateTime.now());
String randomString = RandomStringUtils.randomNumeric(8);
return time + randomString;
}
}
标签:Java,String,订单号,生成,RandomStringUtils,time,import
From: https://www.cnblogs.com/AnNing21/p/17434731.html