svn commit: r1823931 - in /ofbiz/ofbiz-framework/trunk: applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/ applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/ applications/accounting/src/main/java/org/apac...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1823931 - in /ofbiz/ofbiz-framework/trunk: applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/ applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/ applications/accounting/src/main/java/org/apac...

jleroux@apache.org
Author: jleroux
Date: Mon Feb 12 10:04:29 2018
New Revision: 1823931

URL: http://svn.apache.org/viewvc?rev=1823931&view=rev
Log:
Improved: [DEPRECATION] Replace BigDecimal.ROUND_* by RoundingMode.*
(OFBIZ-9571)

UtilNumber class
 Deprecates and replaces both getBigDecimalRoundingMode() by getRoundingMode()
 Deprecates toPercentString()
 Puts a log for a NumberFormatException

Calculate class
 Uses RoundingMode where necessary. No deprecation, this should be only used
 by Minilang

The rest
 Adapts the whole code for that
 

Modified:
    ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java
    ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceWorker.java
    ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentWorker.java
    ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/tax/TaxAuthorityServices.java
    ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java
    ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/cybersource/IcsPaymentServices.java
    ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/PcChargeServices.java
    ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/RitaServices.java
    ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/ideal/IdealEvents.java
    ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/orbital/OrbitalPaymentServices.java
    ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/finaccount/FinAccountHelper.java
    ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReadHelper.java
    ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java
    ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutHelper.java
    ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java
    ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductPromoWorker.java
    ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/price/PriceServices.java
    ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentServices.java
    ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/ups/UpsServices.java
    ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/weightPackage/WeightPackageSession.java
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java
    ofbiz/ofbiz-framework/trunk/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/otherops/Calculate.java

Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java?rev=1823931&r1=1823930&r2=1823931&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java Mon Feb 12 10:04:29 2018
@@ -22,6 +22,7 @@ import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.StringReader;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.nio.ByteBuffer;
 import java.nio.charset.Charset;
 import java.sql.Timestamp;
@@ -109,9 +110,9 @@ public class InvoiceServices {
     // set some BigDecimal properties
     private static final BigDecimal ZERO = BigDecimal.ZERO;
     private static final int DECIMALS = UtilNumber.getBigDecimalScale("invoice.decimals");
-    private static final int ROUNDING = UtilNumber.getBigDecimalRoundingMode("invoice.rounding");
+    private static final RoundingMode ROUNDING = UtilNumber.getRoundingMode("invoice.rounding");
     private static final int TAX_DECIMALS = UtilNumber.getBigDecimalScale("salestax.calc.decimals");
-    private static final int TAX_ROUNDING = UtilNumber.getBigDecimalRoundingMode("salestax.rounding");
+    private static final RoundingMode TAX_ROUNDING = UtilNumber.getRoundingMode("salestax.rounding");
     private static final int INVOICE_ITEM_SEQUENCE_ID_DIGITS = 5; // this is the number of digits used for invoiceItemSeqId: 00001, 00002...
 
     public static final String resource = "AccountingUiLabels";
@@ -155,7 +156,7 @@ public class InvoiceServices {
         GenericValue userLogin = (GenericValue) context.get("userLogin");
         Locale locale = (Locale) context.get("locale");
 
-        if (DECIMALS == -1 || ROUNDING == -1) {
+        if (DECIMALS == -1 || ROUNDING == null) {
             return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                     "AccountingAritmeticPropertiesNotConfigured", locale));
         }
@@ -2314,7 +2315,7 @@ public class InvoiceServices {
         GenericValue userLogin = (GenericValue) context.get("userLogin");
         Locale locale = (Locale) context.get("locale");
 
-        if (DECIMALS == -1 || ROUNDING == -1) {
+        if (DECIMALS == -1 || ROUNDING == null) {
             return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                     "AccountingAritmeticPropertiesNotConfigured", locale));
         }
@@ -2411,7 +2412,7 @@ public class InvoiceServices {
     }
 
     private static BigDecimal calcHeaderAdj(Delegator delegator, GenericValue adj, String invoiceTypeId, String invoiceId, String invoiceItemSeqId,
-            BigDecimal divisor, BigDecimal multiplier, BigDecimal baseAmount, int decimals, int rounding, GenericValue userLogin, LocalDispatcher dispatcher, Locale locale) {
+            BigDecimal divisor, BigDecimal multiplier, BigDecimal baseAmount, int decimals, RoundingMode rounding, GenericValue userLogin, LocalDispatcher dispatcher, Locale locale) {
         BigDecimal adjAmount = ZERO;
         if (adj.get("amount") != null) {
 
@@ -2601,7 +2602,7 @@ public class InvoiceServices {
         Delegator delegator = dctx.getDelegator();
         Locale locale = (Locale) context.get("locale");
 
-        if (DECIMALS == -1 || ROUNDING == -1) {
+        if (DECIMALS == -1 || ROUNDING == null) {
             return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                     "AccountingAritmeticPropertiesNotConfigured", locale));
         }
@@ -3402,7 +3403,7 @@ public class InvoiceServices {
             Debug.logInfo("Start updating the paymentApplication table ", module);
         }
 
-        if (DECIMALS == -1 || ROUNDING == -1) {
+        if (DECIMALS == -1 || ROUNDING == null) {
             return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                     "AccountingAritmeticPropertiesNotConfigured", locale));
         }

Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceWorker.java?rev=1823931&r1=1823930&r2=1823931&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceWorker.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceWorker.java Mon Feb 12 10:04:29 2018
@@ -20,6 +20,7 @@ package org.apache.ofbiz.accounting.invo
 
 import java.math.BigDecimal;
 import java.math.MathContext;
+import java.math.RoundingMode;
 import java.sql.Timestamp;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -52,9 +53,9 @@ public final class InvoiceWorker {
     public static final String module = InvoiceWorker.class.getName();
     private static final BigDecimal ZERO = BigDecimal.ZERO;
     private static final int decimals = UtilNumber.getBigDecimalScale("invoice.decimals");
-    private static final int rounding = UtilNumber.getBigDecimalRoundingMode("invoice.rounding");
+    private static final RoundingMode rounding = UtilNumber.getRoundingMode("invoice.rounding");
     private static final int taxDecimals = UtilNumber.getBigDecimalScale("salestax.calc.decimals");
-    private static final int taxRounding = UtilNumber.getBigDecimalRoundingMode("salestax.rounding");
+    private static final RoundingMode taxRounding = UtilNumber.getRoundingMode("salestax.rounding");
 
     private InvoiceWorker () {}
 

Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentWorker.java?rev=1823931&r1=1823930&r2=1823931&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentWorker.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentWorker.java Mon Feb 12 10:04:29 2018
@@ -20,6 +20,7 @@ package org.apache.ofbiz.accounting.paym
 
 import java.math.BigDecimal;
 import java.math.MathContext;
+import java.math.RoundingMode;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
@@ -49,7 +50,7 @@ public final class PaymentWorker {
 
     public static final String module = PaymentWorker.class.getName();
     private static final int decimals = UtilNumber.getBigDecimalScale("invoice.decimals");
-    private static final int rounding = UtilNumber.getBigDecimalRoundingMode("invoice.rounding");
+    private static final RoundingMode rounding = UtilNumber.getRoundingMode("invoice.rounding");
 
     private PaymentWorker() {}
 

Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/tax/TaxAuthorityServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/tax/TaxAuthorityServices.java?rev=1823931&r1=1823930&r2=1823931&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/tax/TaxAuthorityServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/tax/TaxAuthorityServices.java Mon Feb 12 10:04:29 2018
@@ -60,7 +60,7 @@ public class TaxAuthorityServices {
     public static final BigDecimal PERCENT_SCALE = new BigDecimal("100.000");
     public static final int salestaxFinalDecimals = UtilNumber.getBigDecimalScale("salestax.final.decimals");
     public static final int salestaxCalcDecimals = UtilNumber.getBigDecimalScale("salestax.calc.decimals");
-    public static final int salestaxRounding = UtilNumber.getBigDecimalRoundingMode("salestax.rounding");
+    public static final RoundingMode salestaxRounding = UtilNumber.getRoundingMode("salestax.rounding");
     public static final String resource = "AccountingUiLabels";
 
     public static Map<String, Object> rateProductTaxCalcForDisplay(DispatchContext dctx, Map<String, ? extends Object> context) {

Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java?rev=1823931&r1=1823930&r2=1823931&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java Mon Feb 12 10:04:29 2018
@@ -21,6 +21,7 @@ package org.apache.ofbiz.accounting.thir
 import java.io.ByteArrayOutputStream;
 import java.io.OutputStream;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
@@ -54,7 +55,7 @@ public class CCPaymentServices {
 
     public final static String module = CCPaymentServices.class.getName();
     private static int decimals = UtilNumber.getBigDecimalScale("invoice.decimals");
-    private static int rounding = UtilNumber.getBigDecimalRoundingMode("invoice.rounding");
+    private static RoundingMode rounding = UtilNumber.getRoundingMode("invoice.rounding");
     public final static String resource = "AccountingUiLabels";
     private final static int maxSevComp = 4;
 

Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/cybersource/IcsPaymentServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/cybersource/IcsPaymentServices.java?rev=1823931&r1=1823930&r2=1823931&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/cybersource/IcsPaymentServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/cybersource/IcsPaymentServices.java Mon Feb 12 10:04:29 2018
@@ -53,7 +53,7 @@ public class IcsPaymentServices {
 
     public static final String module = IcsPaymentServices.class.getName();
     private static int decimals = UtilNumber.getBigDecimalScale("invoice.decimals");
-    private static int rounding = UtilNumber.getBigDecimalRoundingMode("invoice.rounding");
+    private static RoundingMode rounding = UtilNumber.getRoundingMode("invoice.rounding");
     public final static String resource = "AccountingUiLabels";
 
     // load the JSSE properties

Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/PcChargeServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/PcChargeServices.java?rev=1823931&r1=1823930&r2=1823931&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/PcChargeServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/PcChargeServices.java Mon Feb 12 10:04:29 2018
@@ -20,6 +20,7 @@ package org.apache.ofbiz.accounting.thir
 
 import java.io.IOException;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -43,7 +44,7 @@ public class PcChargeServices {
 
     public static final String module = PcChargeServices.class.getName();
     private static int decimals = UtilNumber.getBigDecimalScale("invoice.decimals");
-    private static int rounding = UtilNumber.getBigDecimalRoundingMode("invoice.rounding");
+    private static RoundingMode rounding = UtilNumber.getRoundingMode("invoice.rounding");
     public final static String resource = "AccountingUiLabels";
 
     public static Map<String, Object> ccAuth(DispatchContext dctx, Map<String, ? extends Object> context) {

Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/RitaServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/RitaServices.java?rev=1823931&r1=1823930&r2=1823931&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/RitaServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/RitaServices.java Mon Feb 12 10:04:29 2018
@@ -20,6 +20,7 @@ package org.apache.ofbiz.accounting.thir
 
 import java.io.IOException;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.sql.Timestamp;
 import java.util.List;
 import java.util.Locale;
@@ -48,7 +49,7 @@ public class RitaServices {
 
     public static final String module = RitaServices.class.getName();
     private static int decimals = UtilNumber.getBigDecimalScale("invoice.decimals");
-    private static int rounding = UtilNumber.getBigDecimalRoundingMode("invoice.rounding");
+    private static RoundingMode rounding = UtilNumber.getRoundingMode("invoice.rounding");
     public final static String resource = "AccountingUiLabels";
     public static final String resourceOrder = "OrderUiLabels";
 

Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/ideal/IdealEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/ideal/IdealEvents.java?rev=1823931&r1=1823930&r2=1823931&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/ideal/IdealEvents.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/ideal/IdealEvents.java Mon Feb 12 10:04:29 2018
@@ -66,7 +66,7 @@ public class IdealEvents {
     public static final String resourceErr = "AccountingErrorUiLabels";
     public static final String module = IdealEvents.class.getName();
     private static int decimals = UtilNumber.getBigDecimalScale("invoice.decimals");
-    private static int rounding = UtilNumber.getBigDecimalRoundingMode("invoice.rounding");
+    private static RoundingMode rounding = UtilNumber.getRoundingMode("invoice.rounding");
 
     /** Initiate iDEAL Request */
     public static String callIdeal(HttpServletRequest request, HttpServletResponse response) {

Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/orbital/OrbitalPaymentServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/orbital/OrbitalPaymentServices.java?rev=1823931&r1=1823930&r2=1823931&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/orbital/OrbitalPaymentServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/orbital/OrbitalPaymentServices.java Mon Feb 12 10:04:29 2018
@@ -53,7 +53,7 @@ public class OrbitalPaymentServices {
 
     public static String module = OrbitalPaymentServices.class.getName();
     private static int decimals = UtilNumber.getBigDecimalScale("invoice.decimals");
-    private static int rounding = UtilNumber.getBigDecimalRoundingMode("invoice.rounding");
+    private static RoundingMode rounding = UtilNumber.getRoundingMode("invoice.rounding");
     public final static String resource = "AccountingUiLabels";
 
     public static String ERROR    = "Error";

Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/finaccount/FinAccountHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/finaccount/FinAccountHelper.java?rev=1823931&r1=1823930&r2=1823931&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/finaccount/FinAccountHelper.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/finaccount/FinAccountHelper.java Mon Feb 12 10:04:29 2018
@@ -20,6 +20,7 @@
 package org.apache.ofbiz.order.finaccount;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.sql.Timestamp;
 import java.util.List;
 import java.util.Locale;
@@ -48,7 +49,7 @@ public class FinAccountHelper {
       * A word on precision: since we're just adding and subtracting, the interim figures should have one more decimal place of precision than the final numbers.
       */
      public static final int decimals = UtilNumber.getBigDecimalScale("finaccount.decimals");
-     public static final int rounding = UtilNumber.getBigDecimalRoundingMode("finaccount.rounding");
+     public static final RoundingMode rounding = UtilNumber.getRoundingMode("finaccount.rounding");
      public static final BigDecimal ZERO = BigDecimal.ZERO.setScale(decimals, rounding);
 
      public static final String giftCertFinAccountTypeId = "GIFTCERT_ACCOUNT";
@@ -76,7 +77,7 @@ public class FinAccountHelper {
       * @return the new value in a BigDecimal field
       * @throws GenericEntityException
       */
-     public static BigDecimal addFirstEntryAmount(BigDecimal initialValue, List<GenericValue> transactions, String fieldName, int decimals, int rounding) throws GenericEntityException {
+     public static BigDecimal addFirstEntryAmount(BigDecimal initialValue, List<GenericValue> transactions, String fieldName, int decimals, RoundingMode rounding) throws GenericEntityException {
           if ((transactions != null) && (transactions.size() == 1)) {
               GenericValue firstEntry = transactions.get(0);
               if (firstEntry.get(fieldName) != null) {

Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReadHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReadHelper.java?rev=1823931&r1=1823930&r2=1823931&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReadHelper.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReadHelper.java Mon Feb 12 10:04:29 2018
@@ -19,6 +19,7 @@
 package org.apache.ofbiz.order.order;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -66,10 +67,10 @@ public class OrderReadHelper {
 
     // scales and rounding modes for BigDecimal math
     public static final int scale = UtilNumber.getBigDecimalScale("order.decimals");
-    public static final int rounding = UtilNumber.getBigDecimalRoundingMode("order.rounding");
+    public static final RoundingMode rounding = UtilNumber.getRoundingMode("order.rounding");
     public static final int taxCalcScale = UtilNumber.getBigDecimalScale("salestax.calc.decimals");
     public static final int taxFinalScale = UtilNumber.getBigDecimalScale("salestax.final.decimals");
-    public static final int taxRounding = UtilNumber.getBigDecimalRoundingMode("salestax.rounding");
+    public static final RoundingMode taxRounding = UtilNumber.getRoundingMode("salestax.rounding");
     public static final BigDecimal ZERO = (BigDecimal.ZERO).setScale(scale, rounding);
     public static final BigDecimal percentage = (new BigDecimal("0.01")).setScale(scale, rounding);
 

Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java?rev=1823931&r1=1823930&r2=1823931&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java Mon Feb 12 10:04:29 2018
@@ -19,6 +19,7 @@
 package org.apache.ofbiz.order.order;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -36,6 +37,8 @@ import java.util.concurrent.Callable;
 
 import javax.transaction.Transaction;
 
+import org.apache.commons.lang.StringUtils;
+import org.apache.fop.apps.MimeConstants;
 import org.apache.ofbiz.base.util.Debug;
 import org.apache.ofbiz.base.util.GeneralException;
 import org.apache.ofbiz.base.util.GeneralRuntimeException;
@@ -83,9 +86,6 @@ import org.apache.ofbiz.service.ServiceU
 
 import com.ibm.icu.util.Calendar;
 
-import org.apache.commons.lang.StringUtils;
-import org.apache.fop.apps.MimeConstants;
-
 /**
  * Order Processing Services
  */
@@ -112,9 +112,9 @@ public class OrderServices {
         purchaseAttributeRoleMap.put("supplierAgentPartyId", "SUPPLIER_AGENT");
     }
     public static final int taxDecimals = UtilNumber.getBigDecimalScale("salestax.calc.decimals");
-    public static final int taxRounding = UtilNumber.getBigDecimalRoundingMode("salestax.rounding");
+    public static final RoundingMode taxRounding = UtilNumber.getRoundingMode("salestax.rounding");
     public static final int orderDecimals = UtilNumber.getBigDecimalScale("order.decimals");
-    public static final int orderRounding = UtilNumber.getBigDecimalRoundingMode("order.rounding");
+    public static final RoundingMode orderRounding = UtilNumber.getRoundingMode("order.rounding");
     public static final BigDecimal ZERO = BigDecimal.ZERO.setScale(taxDecimals, taxRounding);
 
 

Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutHelper.java?rev=1823931&r1=1823930&r2=1823931&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutHelper.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutHelper.java Mon Feb 12 10:04:29 2018
@@ -19,6 +19,7 @@
 package org.apache.ofbiz.order.shoppingcart;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -74,7 +75,7 @@ public class CheckOutHelper {
     public static final String resource_error = "OrderErrorUiLabels";
 
     public static final int scale = UtilNumber.getBigDecimalScale("order.decimals");
-    public static final int rounding = UtilNumber.getBigDecimalRoundingMode("order.rounding");
+    public static final RoundingMode rounding = UtilNumber.getRoundingMode("order.rounding");
 
     protected LocalDispatcher dispatcher = null;
     protected Delegator delegator = null;

Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java?rev=1823931&r1=1823930&r2=1823931&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java Mon Feb 12 10:04:29 2018
@@ -90,10 +90,10 @@ public class ShoppingCart implements Ite
 
     // scales and rounding modes for BigDecimal math
     public static final int scale = UtilNumber.getBigDecimalScale("order.decimals");
-    public static final int rounding = UtilNumber.getBigDecimalRoundingMode("order.rounding");
+    public static final RoundingMode rounding = UtilNumber.getRoundingMode("order.rounding");
     public static final int taxCalcScale = UtilNumber.getBigDecimalScale("salestax.calc.decimals");
     public static final int taxFinalScale = UtilNumber.getBigDecimalScale("salestax.final.decimals");
-    public static final int taxRounding = UtilNumber.getBigDecimalRoundingMode("salestax.rounding");
+    public static final RoundingMode taxRounding = UtilNumber.getRoundingMode("salestax.rounding");
     public static final BigDecimal ZERO = BigDecimal.ZERO;
     public static final MathContext generalRounding = new MathContext(10);
 

Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductPromoWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductPromoWorker.java?rev=1823931&r1=1823930&r2=1823931&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductPromoWorker.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductPromoWorker.java Mon Feb 12 10:04:29 2018
@@ -77,7 +77,7 @@ public final class ProductPromoWorker {
     private static final String resource_error = "OrderErrorUiLabels";
 
     private static final int decimals = UtilNumber.getBigDecimalScale("order.decimals");
-    private static final int rounding = UtilNumber.getBigDecimalRoundingMode("order.rounding");
+    private static final RoundingMode rounding = UtilNumber.getRoundingMode("order.rounding");
 
     private static final MathContext generalRounding = new MathContext(10);
 

Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/price/PriceServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/price/PriceServices.java?rev=1823931&r1=1823930&r2=1823931&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/price/PriceServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/price/PriceServices.java Mon Feb 12 10:04:29 2018
@@ -19,6 +19,7 @@
 package org.apache.ofbiz.product.price;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.sql.Timestamp;
 import java.util.Collection;
 import java.util.HashMap;
@@ -61,7 +62,7 @@ public class PriceServices {
 
     public static final int taxCalcScale = UtilNumber.getBigDecimalScale("salestax.calc.decimals");
     public static final int taxFinalScale = UtilNumber.getBigDecimalScale("salestax.final.decimals");
-    public static final int taxRounding = UtilNumber.getBigDecimalRoundingMode("salestax.rounding");
+    public static final RoundingMode taxRounding = UtilNumber.getRoundingMode("salestax.rounding");
 
     /**
      * <p>Calculates the price of a product from pricing rules given the following input, and of course access to the database:</p>

Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentServices.java?rev=1823931&r1=1823930&r2=1823931&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentServices.java Mon Feb 12 10:04:29 2018
@@ -19,6 +19,7 @@
 package org.apache.ofbiz.shipment.shipment;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.LinkedList;
@@ -60,7 +61,7 @@ public class ShipmentServices {
     public static final String resource = "ProductUiLabels";
     public static final String resource_error = "OrderErrorUiLabels";
     public static final int decimals = UtilNumber.getBigDecimalScale("order.decimals");
-    public static final int rounding = UtilNumber.getBigDecimalRoundingMode("order.rounding");
+    public static final RoundingMode rounding = UtilNumber.getRoundingMode("order.rounding");
     public static final BigDecimal ZERO = BigDecimal.ZERO.setScale(decimals, rounding);
 
     public static Map<String, Object> createShipmentEstimate(DispatchContext dctx, Map<String, ? extends Object> context) {

Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/ups/UpsServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/ups/UpsServices.java?rev=1823931&r1=1823930&r2=1823931&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/ups/UpsServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/ups/UpsServices.java Mon Feb 12 10:04:29 2018
@@ -90,7 +90,7 @@ public class UpsServices {
         }
     }
     public static final int decimals = UtilNumber.getBigDecimalScale("order.decimals");
-    public static final int rounding = UtilNumber.getBigDecimalRoundingMode("order.rounding");
+    public static final RoundingMode rounding = UtilNumber.getRoundingMode("order.rounding");
     public static final MathContext generalRounding = new MathContext(10);
     public static final int returnServiceCode = 8;
     public static final String dateFormatString = "yyyyMMdd";

Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/weightPackage/WeightPackageSession.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/weightPackage/WeightPackageSession.java?rev=1823931&r1=1823930&r2=1823931&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/weightPackage/WeightPackageSession.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/weightPackage/WeightPackageSession.java Mon Feb 12 10:04:29 2018
@@ -20,6 +20,7 @@ package org.apache.ofbiz.shipment.weight
 
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
@@ -67,7 +68,7 @@ public class WeightPackageSession implem
     private transient Delegator _delegator = null;
     private transient LocalDispatcher _dispatcher = null;
     private static BigDecimal ZERO = BigDecimal.ZERO;
-    private static int rounding = UtilNumber.getBigDecimalRoundingMode("invoice.rounding");
+    private static RoundingMode rounding = UtilNumber.getRoundingMode("invoice.rounding");
 
     public WeightPackageSession() {
     }

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java?rev=1823931&r1=1823930&r2=1823931&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java Mon Feb 12 10:04:29 2018
@@ -20,6 +20,7 @@
 package org.apache.ofbiz.base.util;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.HashMap;
 import java.util.Locale;
 
@@ -34,7 +35,7 @@ public final class UtilNumber {
 
     // default scale and rounding mode for BigDecimals
     private static final int DEFAULT_BD_SCALE = 2;
-    private static final int DEFAULT_BD_ROUNDING_MODE = BigDecimal.ROUND_HALF_UP;
+    private static final RoundingMode DEFAULT_BD_ROUNDING_MODE = RoundingMode.HALF_UP;
 
     // ICU4J rule sets for the en_US locale. To add more rules, expand this string.
     // For reference, see the RbnfSampleRuleSets.java file distributed with ICU4J
@@ -192,6 +193,7 @@ public final class UtilNumber {
             try {
                 scale = Integer.parseInt(value);
             } catch (NumberFormatException e) {
+                Debug.logWarning(e, e.getMessage(), module);
             }
         if (scale == -1) {
             Debug.logWarning("Could not set decimal precision from " + property + "=" + value + ". Using default scale of " + DEFAULT_BD_SCALE + ".", module);
@@ -211,57 +213,77 @@ public final class UtilNumber {
      * Method to get BigDecimal rounding mode from a property
      * @param   file     - Name of the property file
      * @param   property - Name of the config property from arithmeticPropertiesFile (e.g., "invoice.rounding")
-     * @return  int - Rounding mode to pass to BigDecimal's methods. Defaults to DEFAULT_BD_ROUNDING_MODE (BigDecimal.ROUND_HALF_UP)
+     * @return  int - Rounding mode to pass to BigDecimal's methods. Defaults to DEFAULT_BD_ROUNDING_MODE (RoundingMode.HALF_UP)
+     * @deprecated Use {@link #getRoundingMode(String,String)} instead
      */
-    public static int getBigDecimalRoundingMode(String file, String property) {
+    public static int  getBigDecimalRoundingMode(String file, String property) {
+        return getRoundingMode(file, property).ordinal();
+    }
+
+    /**
+     * As above, but use the default properties file
+     * @param   property - Name of the config property from arithmeticPropertiesFile (e.g., "invoice.rounding")
+     * @return  int - Rounding mode to pass to BigDecimal's methods. Defaults to DEFAULT_BD_ROUNDING_MODE (RoundingMode.HALF_UP)
+     * @deprecated Use {@link #getRoundingMode(String)} instead
+     */
+    public static int getBigDecimalRoundingMode(String property) {
+        return getRoundingMode(arithmeticPropertiesFile, property).ordinal();
+    }
+
+    /**
+     * Method to get BigDecimal rounding mode from a property
+     * @param   file     - Name of the property file
+     * @param   property - Name of the config property from arithmeticPropertiesFile (e.g., "invoice.rounding")
+     * @return  RoundingMode - Rounding mode to pass to BigDecimal's methods. Defaults to DEFAULT_BD_ROUNDING_MODE (RoundingMode.HALF_UP)
+     */
+    public static RoundingMode getRoundingMode(String file, String property) {
         if (UtilValidate.isEmpty(file) || UtilValidate.isEmpty(property)) {
             return DEFAULT_BD_ROUNDING_MODE;
         }
 
         String value = UtilProperties.getPropertyValue(file, property);
-        int mode = roundingModeFromString(value);
-        if (mode == -1) {
+        RoundingMode mode = roundingModeFromString(value);
+        if (mode == null) {
             Debug.logWarning("Could not set decimal rounding mode from " + property + "=" + value + ". Using default mode of " + DEFAULT_BD_SCALE + ".", module);
             return DEFAULT_BD_ROUNDING_MODE;
         }
         return mode;
     }
-
     /**
      * As above, but use the default properties file
      */
-    public static int getBigDecimalRoundingMode(String property) {
-        return getBigDecimalRoundingMode(arithmeticPropertiesFile, property);
+    public static RoundingMode getRoundingMode(String property) {
+        return getRoundingMode(arithmeticPropertiesFile, property);
     }
 
     /**
-     * Method to get the BigDecimal rounding mode int value from a string name.
+     * Method to get the RoundingMode rounding mode int value from a string name.
      * @param   value - The name of the mode (e.g., "ROUND_HALF_UP")
-     * @return  int - The int value of the mode (e.g, BigDecimal.ROUND_HALF_UP) or -1 if the input was bad.
+     * @return  RoundingMode - The int value of the mode (e.g, RoundingMode.HALF_UP) or null if the input was bad.
      */
-    public static int roundingModeFromString(String value) {
+    public static RoundingMode roundingModeFromString(String value) {
         if (value == null) {
-            return -1;
+            return null;
         }
         value = value.trim();
         if ("ROUND_HALF_UP".equals(value)) {
-            return BigDecimal.ROUND_HALF_UP;
+            return RoundingMode.HALF_UP;
         } else if ("ROUND_HALF_DOWN".equals(value)) {
-            return BigDecimal.ROUND_HALF_DOWN;
+            return RoundingMode.HALF_DOWN;
         } else if ("ROUND_HALF_EVEN".equals(value)) {
-            return BigDecimal.ROUND_HALF_EVEN;
+            return RoundingMode.HALF_EVEN;
         } else if ("ROUND_UP".equals(value)) {
-            return BigDecimal.ROUND_UP;
+            return RoundingMode.UP;
         } else if ("ROUND_DOWN".equals(value)) {
-            return BigDecimal.ROUND_DOWN;
+            return RoundingMode.DOWN;
         } else if ("ROUND_CEILING".equals(value)) {
-            return BigDecimal.ROUND_CEILING;
+            return RoundingMode.CEILING;
         } else if ("ROUND_FLOOR".equals(value)) {
-            return BigDecimal.ROUND_FLOOR;
+            return RoundingMode.FLOOR;
         } else if ("ROUND_UNNECCESSARY".equals(value)) {
-            return BigDecimal.ROUND_UNNECESSARY;
+            return RoundingMode.UNNECESSARY;
         }
-        return -1;
+        return null;
     }
 
     /**
@@ -313,11 +335,36 @@ public final class UtilNumber {
      * @param scale     How many places after the decimal to include
      * @param roundingMode  The BigDecimal rounding mode to apply
      * @return          The formatted string or "" if there were errors.
+     * @deprecated Use {@link #toPercentString(Number number, int scale, RoundingMode roundingMode)} instead
+     *
      */
     public static String toPercentString(Number number, int scale, int roundingMode) {
         // convert to BigDecimal
         if (!(number instanceof BigDecimal)) {
             number = new BigDecimal(number.doubleValue());
+        }
+
+        // cast it so we can use BigDecimal methods
+        BigDecimal bd = (BigDecimal) number;
+
+        // multiply by 100 and set the scale
+        bd = bd.multiply(new BigDecimal(100.0)).setScale(scale, roundingMode);
+
+        return (bd.toString() + "%");
+    }
+
+    /**
+     * Method to turn a number such as "0.9853" into a nicely formatted percent, "98.53%".
+     *
+     * @param number    The number object to format
+     * @param scale     How many places after the decimal to include
+     * @param roundingMode  the RoundingMode rounding mode to apply
+     * @return          The formatted string or "" if there were errors.
+     */
+    public static String toPercentString(Number number, int scale, RoundingMode roundingMode) {
+        // convert to BigDecimal
+        if (!(number instanceof BigDecimal)) {
+            number = new BigDecimal(number.doubleValue());
         }
 
         // cast it so we can use BigDecimal methods

Modified: ofbiz/ofbiz-framework/trunk/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/otherops/Calculate.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/otherops/Calculate.java?rev=1823931&r1=1823930&r2=1823931&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/otherops/Calculate.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/otherops/Calculate.java Mon Feb 12 10:04:29 2018
@@ -19,6 +19,7 @@
 package org.apache.ofbiz.minilang.method.otherops;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.text.DecimalFormat;
 import java.util.List;
 import java.util.Locale;
@@ -109,21 +110,21 @@ public final class Calculate extends Met
     @Override
     public boolean exec(MethodContext methodContext) throws MiniLangException {
         String roundingModeString = roundingModeFse.expandString(methodContext.getEnvMap());
-        int roundingMode = BigDecimal.ROUND_HALF_EVEN;
+        RoundingMode roundingMode = RoundingMode.HALF_EVEN;
         if ("Ceiling".equals(roundingModeString)) {
-            roundingMode = BigDecimal.ROUND_CEILING;
+            roundingMode = RoundingMode.CEILING;
         } else if ("Floor".equals(roundingModeString)) {
-            roundingMode = BigDecimal.ROUND_FLOOR;
+            roundingMode = RoundingMode.FLOOR;
         } else if ("Up".equals(roundingModeString)) {
-            roundingMode = BigDecimal.ROUND_UP;
+            roundingMode = RoundingMode.UP;
         } else if ("Down".equals(roundingModeString)) {
-            roundingMode = BigDecimal.ROUND_DOWN;
+            roundingMode = RoundingMode.DOWN;
         } else if ("HalfUp".equals(roundingModeString)) {
-            roundingMode = BigDecimal.ROUND_HALF_UP;
+            roundingMode = RoundingMode.HALF_UP;
         } else if ("HalfDown".equals(roundingModeString)) {
-            roundingMode = BigDecimal.ROUND_HALF_DOWN;
+            roundingMode = RoundingMode.HALF_DOWN;
         } else if ("Unnecessary".equals(roundingModeString)) {
-            roundingMode = BigDecimal.ROUND_UNNECESSARY;
+            roundingMode = RoundingMode.UNNECESSARY;
         }
         String decimalScaleString = decimalScaleFse.expandString(methodContext.getEnvMap());
         int decimalScale = 2;
@@ -196,7 +197,7 @@ public final class Calculate extends Met
      * Interface for &lt;calculate&gt; sub-element implementations.
      */
     public interface SubCalc {
-        BigDecimal calcValue(MethodContext methodContext, int scale, int roundingMode) throws MiniLangException;
+        BigDecimal calcValue(MethodContext methodContext, int scale, RoundingMode roundingMode) throws MiniLangException;
     }
 
     /**
@@ -253,7 +254,7 @@ public final class Calculate extends Met
         }
 
         @Override
-        public BigDecimal calcValue(MethodContext methodContext, int scale, int roundingMode) throws MiniLangException {
+        public BigDecimal calcValue(MethodContext methodContext, int scale, RoundingMode roundingMode) throws MiniLangException {
             BigDecimal resultValue = BigDecimal.ZERO.setScale(scale, roundingMode);
             boolean isFirst = true;
             Object fieldObj = fieldFma.get(methodContext.getEnvMap());
@@ -323,7 +324,7 @@ public final class Calculate extends Met
         }
 
         @Override
-        public BigDecimal calcValue(MethodContext methodContext, int scale, int roundingMode) throws MiniLangException {
+        public BigDecimal calcValue(MethodContext methodContext, int scale, RoundingMode roundingMode) throws MiniLangException {
             String valueStr = valueFse.expandString(methodContext.getEnvMap());
             Locale locale = methodContext.getLocale();
             if (locale == null)
@@ -344,7 +345,7 @@ public final class Calculate extends Met
         }
 
         @Override
-        public BigDecimal calcValue(MethodContext methodContext, int scale, int roundingMode) throws MiniLangException {
+        public BigDecimal calcValue(MethodContext methodContext, int scale, RoundingMode roundingMode) throws MiniLangException {
             throw new MiniLangRuntimeException("Invalid calculate sub-element.", this);
         }
     }