Converting String to Money

960 Views Asked by At

I am having the below String

String money = "USD0.00" 

Want to convert this into org.joda.money.Money

Do I need to split the currency unit and double value here and need to set it as separately in Money. Or Any library api is there to convert this?

1

There are 1 best solutions below

0
On BEST ANSWER

You can use Money.parse().

From the documentation (emphasis mine)

The string format is '$currencyCode $amount' where there may be zero to many spaces between the two parts.