OrderNoUtil.java
897 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package org.springblade.common.utils;
import org.springframework.util.ObjectUtils;
import java.sql.Array;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
public class OrderNoUtil {
public static String getOrderNoForRepare(){
Date t = new Date();
SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
String orderNo = df.format(t)+getRandomNo(4);
return orderNo;
}
public static String getRandomNo(int length ){
String result = "";
java.util.Random r=new java.util.Random();
for(int i=0;i<length;i++){
result +=r.nextInt();
}
return result;
}
public static String getSimNO(){
Date t = new Date();
SimpleDateFormat df = new SimpleDateFormat("yyMMddHHmmss");
String orderNo = df.format(t)+getRandomNo(2).replaceAll("-","");
for(int i=0;i<(32-orderNo.length());i++){
orderNo += "0";
}
return orderNo;
}
}