From 8abcf5f9f8fcc12ddb486f580d64f96873531831 Mon Sep 17 00:00:00 2001 From: thinkgem Date: Sat, 10 Jul 2021 16:34:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20ObjectUtils.toDouble=20?= =?UTF-8?q?=E6=94=AF=E6=8C=81=20=E5=AD=97=E7=AC=A6=E4=B8=B2=E5=B8=A6=20*?= =?UTF-8?q?=20=E7=9B=B8=E4=B9=98=E5=86=99=E6=B3=95=EF=BC=8C=E6=96=B9?= =?UTF-8?q?=E4=BE=BF=E5=AD=97=E8=8A=82=E8=B5=8B=E5=80=BC=EF=BC=8C=E5=A6=82?= =?UTF-8?q?=2010*1024*1024?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/jeesite/common/lang/ObjectUtils.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/com/jeesite/common/lang/ObjectUtils.java b/common/src/main/java/com/jeesite/common/lang/ObjectUtils.java index eb8913a1..64a6760b 100644 --- a/common/src/main/java/com/jeesite/common/lang/ObjectUtils.java +++ b/common/src/main/java/com/jeesite/common/lang/ObjectUtils.java @@ -11,7 +11,6 @@ import java.lang.reflect.InvocationTargetException; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.math.NumberUtils; import org.nustaq.serialization.FSTConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,7 +34,20 @@ public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils { return 0D; } try { - return NumberUtils.toDouble(StringUtils.trim(val.toString())); + String str = val.toString(); + if (StringUtils.contains(str, "*")) { + Double number = null, d = null; + for (String s : StringUtils.split(str, "*")) { + d = Double.parseDouble(StringUtils.trim(s)); + if (number == null) { + number = d; + } else { + number *= d; + } + } + return number; + } + return Double.parseDouble(StringUtils.trim(str)); } catch (Exception e) { return 0D; } @@ -59,7 +71,7 @@ public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils { * 转换为 Integer 类型 */ public static Integer toInteger(final Object val) { - return toLong(val).intValue(); + return toDouble(val).intValue(); } /**