|
|
@@ -12,7 +12,8 @@ import java.text.DecimalFormat; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
public class NumberUtil { |
|
|
|
private NumberUtil() {} |
|
|
|
private NumberUtil() { |
|
|
|
} |
|
|
|
|
|
|
|
//整数 |
|
|
|
private static DecimalFormat dfLng = new DecimalFormat("##############0"); |
|
|
@@ -271,7 +272,7 @@ public class NumberUtil { |
|
|
|
*/ |
|
|
|
public static String toStdNumberString(double d, boolean isZeroToEmpty) { |
|
|
|
if (isEqualsZero(d)) { |
|
|
|
return isZeroToEmpty ? "" : "0.00"; |
|
|
|
return isZeroToEmpty ? "": "0.00"; |
|
|
|
} |
|
|
|
return stdNumberFormat.format(d); |
|
|
|
} |
|
|
@@ -304,7 +305,7 @@ public class NumberUtil { |
|
|
|
*/ |
|
|
|
public static String toStdPercentNumberStr(double d, boolean isZeroToEmpty) { |
|
|
|
if (d > -0.00000000001 && d < 0.00000000001) { |
|
|
|
return isZeroToEmpty ? "" : "0.00%"; |
|
|
|
return isZeroToEmpty ? "": "0.00%"; |
|
|
|
} |
|
|
|
return toStdNumberString(d * 100) + "%"; |
|
|
|
} |
|
|
@@ -323,7 +324,7 @@ public class NumberUtil { |
|
|
|
*/ |
|
|
|
public static String toStdAmountString(double d, boolean isZeroToEmpty) { |
|
|
|
if (isEqualsZero(d)) { |
|
|
|
return isZeroToEmpty ? "" : "0.00"; |
|
|
|
return isZeroToEmpty ? "": "0.00"; |
|
|
|
} |
|
|
|
return stdAmountFormat.format(d); |
|
|
|
} |
|
|
@@ -410,15 +411,15 @@ public class NumberUtil { |
|
|
|
|
|
|
|
|
|
|
|
public static double chkDbNull(Double v) { |
|
|
|
return v == null ? 0 : v; |
|
|
|
return v == null ? 0: v; |
|
|
|
} |
|
|
|
|
|
|
|
public static double max(double d1, double d2) { |
|
|
|
return compare(d1, d2) < 0 ? d2 : d1; |
|
|
|
return compare(d1, d2) < 0 ? d2: d1; |
|
|
|
} |
|
|
|
|
|
|
|
public static double min(double d1, double d2) { |
|
|
|
return compare(d1, d2) < 0 ? d1 : d2; |
|
|
|
return compare(d1, d2) < 0 ? d1: d2; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@@ -465,6 +466,14 @@ public class NumberUtil { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static int getBoolValue(String s) { |
|
|
|
String value = s.toLowerCase(); |
|
|
|
if ("true".equalsIgnoreCase(value) || "1".equals(value) || "y".equalsIgnoreCase(value)) { |
|
|
|
return 1; |
|
|
|
} |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 计算公式 参数以Map方式传入 |
|
|
|
* |
|
|
@@ -523,13 +532,13 @@ public class NumberUtil { |
|
|
|
|
|
|
|
public static boolean calcExprMapBool(String expr, Map<String, Object> mapVar) { |
|
|
|
Object o = calcExprMapObject(expr, mapVar); |
|
|
|
if (o != null) return (Boolean)o; |
|
|
|
if (o != null) return (Boolean) o; |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
public static boolean calcExprBoolEx(String expr, Object... vars) { |
|
|
|
Object o = calcExprObjectEx(expr, vars); |
|
|
|
if (o != null) return (Boolean)o; |
|
|
|
if (o != null) return (Boolean) o; |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|