joda-money
joda-money copied to clipboard
Add parser for MoneyFormatterBuilder.appendCurrencySymbolLocalized()
Could a parser be added for MoneyFormatterBuilder.appendCurrencySymbolLocalized()
? It would be useful when you get a "$12.34" string as input to pass it directly to joda-money, eg
MoneyFormatter format = new MoneyFormatterBuilder()
.appendCurrencySymbolLocalized()
.appendAmountLocalized()
.toFormatter();
Money simpleMoney = format.parse(input)
On 0.9.1 this gives "java.lang.UnsupportedOperationException: MoneyFomatter has not been configured to be able to parse"
Sounds entirely reasonable. I'm snowed under with work right now, but feel free to try a pull request.
i have the same problem right now, can print a string with localized symbol, but can't use the formatter to parse this string ...
moneyFormatter = new MoneyFormatterBuilder()
.appendAmountLocalized()
.appendLiteral(" ")
.appendCurrencySymbolLocalized()
.toFormatter();
Money money = Money.of(CurrencyUnit.EUR, 12.35);
String moneyAsString = moneyFormatter.withLocale(locale).print(money);
moneyFormatter.parseMoney(moneyAsString);
last call throws this exception
java.lang.UnsupportedOperationException: MoneyFomatter has not been configured to be able to parse
JodaMoney 0.12