joda-money icon indicating copy to clipboard operation
joda-money copied to clipboard

Add parser for MoneyFormatterBuilder.appendCurrencySymbolLocalized()

Open TheLQ opened this issue 10 years ago • 2 comments

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"

TheLQ avatar May 16 '14 22:05 TheLQ

Sounds entirely reasonable. I'm snowed under with work right now, but feel free to try a pull request.

jodastephen avatar May 16 '14 22:05 jodastephen

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

jens-meiss avatar Mar 02 '18 09:03 jens-meiss