linwe
2024-05-29 c10d6358b9f014375a13821465bc978d0c0da22e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package org.springblade.common.utils;
 
import java.util.UUID;
 
public class IdUtils {
 
    /**
     * 随机生成36位id
     * @return
     */
    public static String getIdBy36(){
        //生成uuid
        String randomId = UUID.randomUUID().toString();
        String trim = randomId.replaceAll("-", "");
        //再拼接4位
        long l = System.currentTimeMillis();
        String time = String.valueOf(l);
        String subTime = time.substring(time.length() - 4);
        return trim + subTime;
    }
}