Hi Marco, We have the conversion framework for converting Strings to BigDecimals so there is no need to implement a new method for it: BigDecimal bigDecimal = (BigDecimal) ObjectType.simpleTypeConvert(object, "BigDecimal", null, locale);
Regards Scott On 23/05/2011, at 1:11 AM, mrisal...@apache.org wrote: > Author: mrisaliti > Date: Sun May 22 13:11:17 2011 > New Revision: 1125951 > > URL: http://svn.apache.org/viewvc?rev=1125951&view=rev > Log: > Webpos2 improved version (OFBIZ-4287) > [snip] > > > Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilNumber.java > URL: > http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilNumber.java?rev=1125951&r1=1125950&r2=1125951&view=diff > ============================================================================== > --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilNumber.java > (original) > +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilNumber.java Sun > May 22 13:11:17 2011 > @@ -20,6 +20,8 @@ > package org.ofbiz.base.util; > > import java.math.BigDecimal; > +import java.text.NumberFormat; > +import java.text.ParseException; > import java.util.HashMap; > import java.util.Locale; > > @@ -250,4 +252,27 @@ public class UtilNumber { > > return (bd.toString() + "%"); > } > + > + /** > + * Method to convert a string into BigDecimal. > + * > + * @param stringToConvert String to convert to BigDecimal > + * @return The string converted to BigDecimal > + */ > + public static BigDecimal stringToBigDecimal(String stringToConvert, > Locale locale) { > + if (stringToConvert != null && stringToConvert != "") { > + Number numb = null; > + NumberFormat nf = NumberFormat.getInstance(locale); > + nf.setMaximumFractionDigits(10); > + try { > + numb = nf.parse(stringToConvert); > + return (new BigDecimal(numb.toString())); > + } catch (ParseException e) { > + return null; > + } > + } > + else { > + return null; > + } > + } > } >
smime.p7s
Description: S/MIME cryptographic signature