fuliqi
2024-09-04 3df04e32e4190bfe8a74998f19fedbbfa9747f29
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package com.ycl.utils.uuid;
 
import java.text.SimpleDateFormat;
import java.util.Date;
 
/**
 * ID生成器工具类
 *
 * @author ruoyi
 */
public class IdUtils
{
 
    private final static SimpleDateFormat FORMAT = new SimpleDateFormat("yyyyMMddHHmmss");
    private final static SimpleDateFormat DAY_FORMAT = new SimpleDateFormat("yyyyMMdd");
 
    /**
     * 获取随机UUID
     *
     * @return 随机UUID
     */
    public static String randomUUID()
    {
        return UUID.randomUUID().toString();
    }
 
    /**
     * 简化的UUID,去掉了横线
     *
     * @return 简化的UUID,去掉了横线
     */
    public static String simpleUUID()
    {
        return UUID.randomUUID().toString(true);
    }
 
    /**
     * 获取随机UUID,使用性能更好的ThreadLocalRandom生成UUID
     *
     * @return 随机UUID
     */
    public static String fastUUID()
    {
        return UUID.fastUUID().toString();
    }
 
    /**
     * 简化的UUID,去掉了横线,使用性能更好的ThreadLocalRandom生成UUID
     *
     * @return 简化的UUID,去掉了横线
     */
    public static String fastSimpleUUID()
    {
        return UUID.fastUUID().toString(true);
    }
 
    /**
     * 获取当前时间+随机数的编号
     *
     * @return 编号
     */
    public static String randomNO(Date now)
    {
        return DAY_FORMAT.format(now) + UUID.randomUUID().toString().replaceAll("-","").substring(0, 18);
    }
}