Files
common-library/src/main/java/com/kri/common/feature/util/CommonUtil.java

26 lines
609 B
Java

package com.kri.common.feature.util;
import com.kri.common.feature.web.BusinessException;
import java.util.UUID;
public final class CommonUtil {
private CommonUtil() {
}
public static String uuid32() {
return UUID.randomUUID().toString().replace("-", "");
}
public static String uuid(int length) {
if (length <= 0) {
throw BusinessException.badRequest("length must be greater than 0");
}
if (length > 32) {
throw BusinessException.badRequest("length must be less than 32");
}
return UUID.randomUUID().toString().substring(0, length).replace("-", "");
}
}