Questions tagged [jsr354]

JSR 354: Money and Currency API

Provides an API for representing, transporting, and performing comprehensive calculations with Money and Currency.

28 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
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
2 answers

Find CurrencyUnit from ISO **numeric** currency code

I'm trying to format an amount using the correct formatting rules, given the ISO 4217 numeric currency code. For example, given an amount of 99.99 and numeric code 840, I expect to produce a string 'USD 99.99' or similar. Looking at the JSR 354…
andrew-g-za
  • 967
  • 8
  • 13
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

Customizing a MonetaryAmountFormat using the Moneta (JavaMoney) JSR354 implemenation

I'm really confused about how to customize a MonetaryAmountFormat using the Moneta JSR-354 implementation. My intention is to be able to parse both 1.23 and $3.45 as MonetaryAmounts. Here is my unit test: @Test public void testString() { Bid bid…
dhalsim2
  • 936
  • 2
  • 12
  • 35
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

How to format MonetaryAmount with currency symbol?

Edit: This question is intended to be for formatting within the context of JSR-354. An alternative would be to use java.util.CurrencyFormat. But I want to know how to do it using MonetaryAmountFormat. How do you format a MonetaryAmount using the…
axiopisty
  • 4,972
  • 8
  • 44
  • 73
2
votes
1 answer

Are there any caveats of creating a FastMoney/Money from a double?

I have seen there are issues when creating BigDecimal from double. Although FastMoney doesn't use BigDecimal (as opposed to Money), I am not sure how either of them will behave when I crate them from a double value. Is creating a FastMoney/Money…
Michel Feinstein
  • 13,416
  • 16
  • 91
  • 173
2
votes
1 answer

How to change roundings for MonetaryAmount division in jsr-354

I use jsr-354 org.javamoney.moneta api for Currency. I need to divide money, for example I want set roundings to 0.25 So 100 dollars / 3 should be 33.25 By default val dollar100 = FastMoney.of(100, Monetary.getCurrency(Locale.US)) val res =…
zella
  • 4,645
  • 6
  • 35
  • 60
1
2