From 3df784b1cf0b63fbc035e742a92b998f6630dfdc Mon Sep 17 00:00:00 2001 From: Looly Date: Thu, 23 Jun 2022 18:30:55 +0800 Subject: [PATCH] fix code --- .../src/main/java/cn/hutool/core/math/NumberUtil.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hutool-core/src/main/java/cn/hutool/core/math/NumberUtil.java b/hutool-core/src/main/java/cn/hutool/core/math/NumberUtil.java index 6d40e14f4..1ad8b765c 100644 --- a/hutool-core/src/main/java/cn/hutool/core/math/NumberUtil.java +++ b/hutool-core/src/main/java/cn/hutool/core/math/NumberUtil.java @@ -791,11 +791,10 @@ public class NumberUtil { } try { Double.parseDouble(s); - return s.contains("."); } catch (final NumberFormatException ignore) { - // ignore + return false; } - return true; + return s.contains("."); } /** @@ -1690,6 +1689,9 @@ public class NumberUtil { * @since 4.6.7 */ public static boolean isValidNumber(final Number number) { + if(null == number){ + return false; + } if (number instanceof Double) { return (false == ((Double) number).isInfinite()) && (false == ((Double) number).isNaN()); } else if (number instanceof Float) {