Questions tagged [java-money]

Java Money and Currency API for the Java

JSR 354 JavaMoney Provides a portable and extensible framework for handling of Money & Currency for Java™. The API models monetary amounts and currencies in a platform independent and portable way, including well defined extension points. It's API defines a simple yet flexible contract that enables users to choose the implementation matching their target requirements best and having full control about the numeric state at all stages during monetary processing.

54 questions
9
votes
2 answers

Java's Monetary and Currency Operation - JSR 354

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…
ha9u63a7
  • 6,233
  • 16
  • 73
  • 108
7
votes
1 answer

Overriding properties in javamoney.properties?

Using the new 1.0 version of JavaMoney API with the reference implementation we try to stop the resource-loader from loading other ExchangeRateProvider by overriding javamoney.properties. {1}conversion.default-chain=MY-PROVIDER # Turn off loading of…
Truls
  • 307
  • 3
  • 12
6
votes
1 answer

Java Money - Smallest Unit of currency

I have a downstream service (Stripe) which requires I send currency in the smallest currency unit (zero-decimal currency in their docs). I.e. to charge $1 I would send { "currency": "USD", amount: 100 } and to charge ¥100 I would send { "currency":…
Ben Flowers
  • 1,434
  • 7
  • 21
  • 49
5
votes
1 answer

Convert MonetaryAmount to long of minor units (Javamoney)

Using the JSR-354 Java Money API (Moneta in this case), I can easily create a MonetaryAmount object from a long of minor units (pence in this case): MonetaryAmount amount = Money.ofMinor(Monetary.getCurrency("GBP"), 1234); //£12.34 ...but how do I…
Michael Berry
  • 70,193
  • 21
  • 157
  • 216
5
votes
1 answer

JPA mapping of Monetary Amount

I'm interested in incorporating JSR 354 Money API into my application and would like to be able to map MoneyAmount as Embeddable with JPA but we do not seem able to because the no-arg constructor of the Moneta implementation class is private and JPA…
TheArchitect
  • 2,161
  • 1
  • 12
  • 16
4
votes
1 answer

Validate currency code matches one of the allowed values

I have a POJO, which contains a field called price. The field's type is javax.money.MonetaryAmount, so that I can benefit from JSR 354 validation etc. I have a constraint on the field specifying that the currency must be EUR: @Currency("EUR") How…
bobbyrne01
  • 6,295
  • 19
  • 80
  • 150
4
votes
2 answers

MonetaryException: No MonetaryAmountsSingletonSpi loaded

Problem description I have a java project with gradle dependency from org.javamoney:moneta:1.3. Also I have two Kubernetes clusters. I deploy my java application using docker-container. When I deploy my app in the first Kubernetes cluster everything…
Maksim Iakunin
  • 428
  • 1
  • 4
  • 21
4
votes
1 answer

Java fast money representation?

I'm working on a real time application that deals with money in different currencies and exchange rates using BigDecimal, however I'm facing some serious performance issues and I want to change the underlying representation. I've read again and…
Mattx
  • 65
  • 6
4
votes
1 answer

Java Money - currency conversion rate on specific date

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…
Kiki
  • 2,243
  • 5
  • 30
  • 43
4
votes
1 answer

JSR-354 java money moneta specify proxy

I'm trying to perform money conversion with Moneta API, so I call this: MonetaryConversions.getExchangeRateProvider("IDENT", "ECB", "IMF", "ECB-HIST", "ECB-HIST90").getExchangeRate(sourceCurrency, targetCurrency); Unfortunately I get this…
Petar Tahchiev
  • 4,336
  • 4
  • 35
  • 48
4
votes
2 answers

Is there a way to construct a MonetaryAmount from a whole cents value?

Given a price-point represented as an integer of whole cents, i.e. 199 = $1.99, is there an API method for constructing a MonetaryAmount? One simple method would be to divide the amount by 100, but wondering if there's an API method for…
Brett Ryan
  • 26,937
  • 30
  • 128
  • 163
4
votes
1 answer

What is the recommended way to create an ExchangeRateProvider in JavaMoney (JSR 354)?

We have started using the new 1.0 version of JavaMoney API with the reference implementation. Since we have specific Exchangerates that should be used, we need to implement our own ExchangeRateProvider. We have created a class MyRateProvider that…
Truls
  • 307
  • 3
  • 12
4
votes
2 answers

Java money reference implementation in OSGI

I'm using the Java money (JSR354) reference implementation found here: http://javamoney.github.io/ri.html However, I'm using it in an OSGI environment. This is giving me the following exception: [qtp305372452-33] ERROR…
David ten Hove
  • 2,748
  • 18
  • 33
3
votes
1 answer

java MonetaryConversions throws ArithmeticException for high digit currencies

I'd like to use standard java MonetaryConversions to convert currencies. At first glance it works very well and simple: @Test public void testConversion() { FastMoney usd = FastMoney.of(1000, Monetary.getCurrency("USD")); …
3
votes
1 answer

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

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…
xetra11
  • 7,671
  • 14
  • 84
  • 159
1
2 3 4