com.hina.sdk.util.IdUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of HinaCloudSDK Show documentation
Show all versions of HinaCloudSDK Show documentation
The official Java SDK of Hina Analytics
The newest version!
package com.hina.sdk.util;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Random;
import java.util.UUID;
public class IdUtil {
// 最新的生成id方法,使用UUID+随机数的方式
public static String generateId(){
UUID uuid = UUID.randomUUID();
String s = uuid.toString();
String m=s.replace("-","");
Random random = new Random();
int fourDigitNumber = 1000 + random.nextInt(9000);
return m+fourDigitNumber;
}
}