svn commit: r935140 - in /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart: ShoppingCartEvents.java ShoppingCartHelper.java

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

svn commit: r935140 - in /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart: ShoppingCartEvents.java ShoppingCartHelper.java

lektran
Author: lektran
Date: Sat Apr 17 07:41:57 2010
New Revision: 935140

URL: http://svn.apache.org/viewvc?rev=935140&view=rev
Log:
Switched a few other String to BigDecimal parsing attempts over to the conversion framework

Modified:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java?rev=935140&r1=935139&r2=935140&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java Sat Apr 17 07:41:57 2010
@@ -37,6 +37,7 @@ import javolution.util.FastList;
 import javolution.util.FastMap;
 
 import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.ObjectType;
 import org.ofbiz.base.util.UtilDateTime;
 import org.ofbiz.base.util.UtilFormatOut;
 import org.ofbiz.base.util.UtilHttp;
@@ -337,7 +338,7 @@ public class ShoppingCartEvents {
                 reservLengthStr = (String) paramMap.remove("reservLength");
                 // parse the reservation Length
                 try {
-                    reservLength = new BigDecimal(nf.parse(reservLengthStr).doubleValue());
+                    reservLength = (BigDecimal) ObjectType.simpleTypeConvert(reservLengthStr, "BigDecimal", null, locale);
                 } catch (Exception e) {
                     Debug.logWarning(e, "Problems parsing reservation length string: "
                             + reservLengthStr, module);
@@ -351,7 +352,7 @@ public class ShoppingCartEvents {
                 reservPersonsStr = (String) paramMap.remove("reservPersons");
                 // parse the number of persons
                 try {
-                    reservPersons = new BigDecimal(nf.parse(reservPersonsStr).doubleValue());
+                    reservPersons = (BigDecimal) ObjectType.simpleTypeConvert(reservPersonsStr, "BigDecimal", null, locale);
                 } catch (Exception e) {
                     Debug.logWarning(e, "Problems parsing reservation number of persons string: " + reservPersonsStr, module);
                     reservPersons = BigDecimal.ONE;
@@ -386,7 +387,7 @@ public class ShoppingCartEvents {
 
         // parse the price
         try {
-            price = new BigDecimal(nf.parse(priceStr).doubleValue());
+            price = (BigDecimal) ObjectType.simpleTypeConvert(priceStr, "BigDecimal", null, locale);
         } catch (Exception e) {
             Debug.logWarning(e, "Problems parsing price string: " + priceStr, module);
             price = null;
@@ -394,7 +395,7 @@ public class ShoppingCartEvents {
 
         // parse the quantity
         try {
-            quantity = new BigDecimal(nf.parse(quantityStr).doubleValue());
+            quantity = (BigDecimal) ObjectType.simpleTypeConvert(quantityStr, "BigDecimal", null, locale);
         } catch (Exception e) {
             Debug.logWarning(e, "Problems parsing quantity string: " + quantityStr, module);
             quantity = BigDecimal.ONE;
@@ -412,7 +413,7 @@ public class ShoppingCartEvents {
         BigDecimal amount = null;
         if (UtilValidate.isNotEmpty(selectedAmountStr)) {
             try {
-                amount = new BigDecimal(nf.parse(selectedAmountStr).doubleValue());
+                amount = (BigDecimal) ObjectType.simpleTypeConvert(selectedAmountStr, "BigDecimal", null, locale);
             } catch (Exception e) {
                 Debug.logWarning(e, "Problem parsing amount string: " + selectedAmountStr, module);
                 amount = null;

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java?rev=935140&r1=935139&r2=935140&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java Sat Apr 17 07:41:57 2010
@@ -21,7 +21,6 @@ package org.ofbiz.order.shoppingcart;
 import java.math.BigDecimal;
 import java.sql.Timestamp;
 import java.text.NumberFormat;
-import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -35,6 +34,7 @@ import java.util.Set;
 import javolution.util.FastMap;
 
 import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.GeneralException;
 import org.ofbiz.base.util.ObjectType;
 import org.ofbiz.base.util.UtilHttp;
 import org.ofbiz.base.util.UtilMisc;
@@ -484,8 +484,8 @@ public class ShoppingCartHelper {
                 if (UtilValidate.isNotEmpty(quantStr)) {
                     BigDecimal quantity = BigDecimal.ZERO;
                     try {
-                        quantity = new BigDecimal(nf.parse(quantStr).doubleValue());
-                    } catch (ParseException nfe) {
+                        quantity = (BigDecimal) ObjectType.simpleTypeConvert(quantStr, "BigDecimal", null, cart.getLocale());
+                    } catch (GeneralException ge) {
                         quantity = BigDecimal.ZERO;
                     }
                     if (quantity.compareTo(BigDecimal.ZERO) > 0) {