Possible Duplicate:
Safe String to BigDecimal conversion
Is there any ultimate parse function in java which can analyze type of the number given in string and return its value in object of class Number or similar.
I would like to convert string into bigDecimal or Number and put t into collection, sometimes I have string like 2.23 or 2,23 or 2 or BigInteger like 233242424242424242.
If all you want is to parse a
Stringto aBigDecimal, you can use the constructor that gets a string as a argument. The constructor takes care of the basic parsing.For complex parsing (involving thousands separators), you can use the methods in the
DecimalFormatclass withsetParseBigDecimalset totrue.