mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix bug
This commit is contained in:
parent
bfa130b564
commit
c72ff2c292
@ -19,6 +19,7 @@
|
|||||||
* 【core 】 修复CAR_VIN正则(pr#624@Gitee)
|
* 【core 】 修复CAR_VIN正则(pr#624@Gitee)
|
||||||
* 【db 】 修复count查询别名问题(issue#I590YB@Gitee)
|
* 【db 】 修复count查询别名问题(issue#I590YB@Gitee)
|
||||||
* 【json 】 修复json中byte[]无法转换问题(issue#I59LW4@Gitee)
|
* 【json 】 修复json中byte[]无法转换问题(issue#I59LW4@Gitee)
|
||||||
|
* 【core 】 修复NumberUtil.isXXX未判空问题(issue#2350@Github)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -1238,10 +1238,12 @@ public class NumberUtil {
|
|||||||
* @return 是否为整数
|
* @return 是否为整数
|
||||||
*/
|
*/
|
||||||
public static boolean isInteger(String s) {
|
public static boolean isInteger(String s) {
|
||||||
try {
|
if(StrUtil.isNotBlank(s)) {
|
||||||
Integer.parseInt(s);
|
try {
|
||||||
} catch (NumberFormatException e) {
|
Integer.parseInt(s);
|
||||||
return false;
|
} catch (NumberFormatException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1255,10 +1257,12 @@ public class NumberUtil {
|
|||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
*/
|
*/
|
||||||
public static boolean isLong(String s) {
|
public static boolean isLong(String s) {
|
||||||
try {
|
if(StrUtil.isNotBlank(s)) {
|
||||||
Long.parseLong(s);
|
try {
|
||||||
} catch (NumberFormatException e) {
|
Long.parseLong(s);
|
||||||
return false;
|
} catch (NumberFormatException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1270,11 +1274,13 @@ public class NumberUtil {
|
|||||||
* @return 是否为{@link Double}类型
|
* @return 是否为{@link Double}类型
|
||||||
*/
|
*/
|
||||||
public static boolean isDouble(String s) {
|
public static boolean isDouble(String s) {
|
||||||
try {
|
if(StrUtil.isNotBlank(s)) {
|
||||||
Double.parseDouble(s);
|
try {
|
||||||
return s.contains(".");
|
Double.parseDouble(s);
|
||||||
} catch (NumberFormatException ignore) {
|
return s.contains(".");
|
||||||
// ignore
|
} catch (NumberFormatException ignore) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -444,4 +444,11 @@ public class NumberUtilTest {
|
|||||||
Assert.assertEquals(1001013, NumberUtil.div(100101300, (Number) 100).intValue());
|
Assert.assertEquals(1001013, NumberUtil.div(100101300, (Number) 100).intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isDoubleTest(){
|
||||||
|
Assert.assertFalse(NumberUtil.isDouble(null));
|
||||||
|
Assert.assertFalse(NumberUtil.isDouble(""));
|
||||||
|
Assert.assertFalse(NumberUtil.isDouble(" "));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user