mirror of
https://gitee.com/dromara/hutool.git
synced 2025-05-04 04:37:59 +08:00
fix RandomUtil
This commit is contained in:
parent
7e8096a75c
commit
07229be2db
@ -14,6 +14,7 @@
|
|||||||
* 【core 】 增加XmlUtil.setNamespaceAware,getByPath支持UniversalNamespaceCache
|
* 【core 】 增加XmlUtil.setNamespaceAware,getByPath支持UniversalNamespaceCache
|
||||||
* 【aop 】 增加Spring-cglib支持,改为SPI实现
|
* 【aop 】 增加Spring-cglib支持,改为SPI实现
|
||||||
* 【json 】 增加JSONUtil.parseXXX增加JSONConfig参数
|
* 【json 】 增加JSONUtil.parseXXX增加JSONConfig参数
|
||||||
|
* 【core 】 RandomUtil.randomNumber改为返回char
|
||||||
|
|
||||||
### Bug修复
|
### Bug修复
|
||||||
* 【json 】 修复解析JSON字符串时配置无法传递问题
|
* 【json 】 修复解析JSON字符串时配置无法传递问题
|
||||||
|
@ -1,5 +1,14 @@
|
|||||||
package cn.hutool.core.util;
|
package cn.hutool.core.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.date.DateField;
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.exceptions.UtilException;
|
||||||
|
import cn.hutool.core.lang.UUID;
|
||||||
|
import cn.hutool.core.lang.WeightRandom;
|
||||||
|
import cn.hutool.core.lang.WeightRandom.WeightObj;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
@ -14,15 +23,6 @@ import java.util.Random;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.date.DateField;
|
|
||||||
import cn.hutool.core.date.DateTime;
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
import cn.hutool.core.exceptions.UtilException;
|
|
||||||
import cn.hutool.core.lang.UUID;
|
|
||||||
import cn.hutool.core.lang.WeightRandom;
|
|
||||||
import cn.hutool.core.lang.WeightRandom.WeightObj;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 随机工具类
|
* 随机工具类
|
||||||
*
|
*
|
||||||
@ -487,7 +487,7 @@ public class RandomUtil {
|
|||||||
* @return 随机数字字符
|
* @return 随机数字字符
|
||||||
* @since 3.1.2
|
* @since 3.1.2
|
||||||
*/
|
*/
|
||||||
public static int randomNumber() {
|
public static char randomNumber() {
|
||||||
return randomChar(BASE_NUMBER);
|
return randomChar(BASE_NUMBER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,9 +3,6 @@ package cn.hutool.core.util;
|
|||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
|
||||||
import cn.hutool.core.util.HexUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HexUtil单元测试
|
* HexUtil单元测试
|
||||||
* @author Looly
|
* @author Looly
|
||||||
|
@ -35,4 +35,10 @@ public class RandomUtilTest {
|
|||||||
public void randomBooleanTest() {
|
public void randomBooleanTest() {
|
||||||
Console.log(RandomUtil.randomBoolean());
|
Console.log(RandomUtil.randomBoolean());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void randomNumberTest() {
|
||||||
|
final char c = RandomUtil.randomNumber();
|
||||||
|
Assert.assertTrue(c <= '9');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user