Java: What is the right way to convert String into a valid amount of money(BigDecimal)

Posted by Midnight Blue on Stack Overflow See other posts from Stack Overflow or by Midnight Blue
Published on 2010-04-08T20:21:59Z Indexed on 2010/04/08 20:23 UTC
Read the original article Hit count: 185

Filed under:
|

Hi, I have to convert an incoming String field into a BigDecimal field that would represent a valid amount of money, for example:

String amount = "1000";

BigDecimal valid_amount = convert(amount);

print(valid_amount.toString())//1000.00

What is the right API to use convert a String into a valid amount of money in Java (eg: apache commons library)?

Thanks in advance,

© Stack Overflow or respective owner

Related posts about java

Related posts about bigdecimal