IdGen工具新增,随机生成指定范围的Integer值

This commit is contained in:
thinkgem
2019-06-26 17:12:26 +08:00
parent bf7daeed16
commit 956b82ba65

View File

@@ -43,6 +43,13 @@ public class IdGenerate {
return EncodeUtils.encodeBase62(randomBytes); return EncodeUtils.encodeBase62(randomBytes);
} }
/**
* 使用SecureRandom随机生成指定范围的Integer.
*/
public static int randomInt(int min, int max) {
return random.nextInt(max) % (max - min + 1) + min;
}
/** /**
* 获取新唯一编号18为数值 * 获取新唯一编号18为数值
* 来自于twitter项目snowflake的id产生方案全局唯一时间有序。 * 来自于twitter项目snowflake的id产生方案全局唯一时间有序。