/**
* 生成订单编号 时间戳+3位整数
* @return
*/
public String autoOrderId(){
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String str = format.format(date);
Date orderId = null;
Random rand = new Random();
//[900]:900个 100:从100
int x = rand.nextInt(900) + 100;
try {
orderId = format.parse(str);
} catch (ParseException e) {
e.printStackTrace();
}
return String.valueOf(orderId.getTime()) + x;
}
时间戳+3位随机数做id
猜你喜欢
转载自blog.csdn.net/weixin_41432270/article/details/83310316
今日推荐
周排行