java-money

CurrencyUnit of javamoney can't be used as class of a field and deserialized by Jackson due InvalidDefinitionException

橙三吉。 提交于 2021-01-27 13:06:41
问题 I have a pojo that has a field of type CurrencyUnit from the javamoney library. When I marshall this pojo Jackson throws an exception. I remember this exception when I did not define any default constructor. But in this case I can not maintain the CurrencyUnit class since it's coming from a dependency. How can I still make this work? Exception: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `javax.money.CurrencyUnit` (no Creators, like default

JSR-354 MonetaryAmountFormat not working two way for other currency symbols than $, € or £

妖精的绣舞 提交于 2019-12-12 20:06:20
问题 Here is example code that I'm using with Moneta version 1.1: Locale LANG = Locale.CHINA; // also tried new Locale("pl", "PL"); final MonetaryAmountFormat format = MonetaryFormats.getAmountFormat( AmountFormatQueryBuilder.of(LANG) .set(CurrencyStyle.SYMBOL) .set("pattern", "#,##0.00### ¤") .build() ); final String formatted = format.format(Money.of(new BigDecimal("1234.56"), Monetary.getCurrency(LANG))); System.out.println(formatted); System.out.println(format.parse(formatted).getNumber());

Java's Monetary and Currency Operation - JSR 354

半腔热情 提交于 2019-12-11 07:56:43
问题 I was just curious if anyone knew whether JSR 354 will have an official implementation as part of any future JDK. JDK 11 JavaDocs JSR354 Reference Implementation When I search JDK 11 docs online - it doesn't look like Monetary and MonetaryAmount classes aren't included. But the implementation of JSR 354 exists in Github under jsr354-ri. Does it mean that I can write my own implementation, if I don't want to follow the reference implementation? My purpose is to support additional currencies e

Java Money - currency conversion rate on specific date

筅森魡賤 提交于 2019-12-10 18:24:48
问题 I'm trying to get exchange rate on specific date between EUR and USD. The issue is I'm allways getting exchange dare for date: LocalDate{year=2016, month=1, dayOfMonth=8} and it does not matter if I specify date in query. Here are my maven dependencies: <dependency> <groupId>javax.money</groupId> <artifactId>money-api-bp</artifactId> <version>1.0.1</version> </dependency> <dependency> <groupId>org.javamoney</groupId> <artifactId>moneta-bp</artifactId> <version>1.1</version> </dependency>