Search code examples
javajava-8joda-money

Converting String to Money


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?


Solution

  • 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.