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
3
votes
1 answer

No MonetaryAmountsSingletonSpi loaded

Dependency added in pom.xml: javax.money money-api 1.0.3 Relevant code: MonetaryAmount mon = Monetary.getDefaultAmountFactory() …
scarkd
  • 33
  • 3
3
votes
0 answers

How to add a ExchangeRateProvider to javax.money

I wrote a custom ExchangeRateProvider that needs dependency injection. But for java.money you need to add your custom class in a file under META-INF/services/javax.money.convert.ExchangeRateProvider. The normal ServiceLoader does not use dependency…
Ben Keil
  • 1,050
  • 1
  • 10
  • 30
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

org.javamoney.moneta.RoundedMoney - some operations result in a rounded value some are not

If i use org.javamoney.moneta and run the following program, i got some contrary results for some operations on org.javamoney.moneta.RoundedMoney. Sometimes the resulted value is rounded some times it is not. Am I using the class wrong or is that a…
rfcmbs
  • 21
  • 3
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
2
votes
0 answers

Handling dates and currencies in data model with Avro or Protobuf

How to handle dates¤cies in my data model with Apache Avro or Google Protobuf, can you point me to an example: How can I serialize and read back a Joda time Datetime? How can I serialize and read back currency datatime? Thank you, Oscar
Luis Trigueiros
  • 636
  • 7
  • 21
2
votes
1 answer

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

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( …
abc
  • 2,371
  • 3
  • 25
  • 36
2
votes
1 answer

Using JSR-354 ExchangeRates prevents application from exiting

I'm trying to use JavaMoney 1.0 in my application and noticed that when using default ExchangeRateProviders, some threads will still be running when my application finishes. public static void main(String[] args) { …
Xavier Dury
  • 1,530
  • 1
  • 16
  • 23
1
vote
1 answer

Convert @Query MonetaryAmount result

I just converted all of my java.math.BigDecimal usages to javax.money.MonetaryAmount (where they represented money). I am currently "assuming" the currency to be USD with the help of a MoneyUtils to avoid adding extra database columns that will only…
arnaldop
  • 333
  • 6
  • 17
1
vote
1 answer

What's the recommended way to format currency symbols in a locale-agnostic way?

Context I want to have a standard way of formatting prices regardless of the locale. Currently, the output format is locale-aware (as with NumberFormat): Monetary amount Format with locale es-ES Format with locale en-US Money.of(1234,…
Gastón Fournier
  • 956
  • 1
  • 9
  • 25
1
vote
0 answers

What is MonetaryAmount.plus() used for? Which Kotlin operator to map it to?

I'm using JSR 354 a.k.a JavaMoney, and I don't understand what MonetaryAmount.plus() is supposed to do? For all implementations of MonetaryAmount I found, it simply returns this. The documentation is not helpful to me: Returns a {@code…
Ynv
  • 1,824
  • 3
  • 20
  • 29
1
vote
1 answer

JSR354 (Java Money API) remaining as javax.money or moving to java.money?

Now that the transfer ballot has taken place and jsr354-api (Java Money API) is set for inclusion in the Java distribution, will its package remain as javax.money or move to java.money? Is the intention of this module-info.java file to allow…
David B
  • 455
  • 6
  • 13
1
vote
1 answer

JavaMoney: set CurrencyStyle without a compile-time dependency on moneta

I'm trying to create a MonetaryAmountFormat that uses the currency unit symbol: MonetaryAmountFormat format = MonetaryFormats.getAmountFormat( AmountFormatQueryBuilder.of(Locale.GERMANY) …
Christian
  • 23
  • 1
  • 7
1
vote
1 answer

what's the difference between jsr354-api and jsr354-ri

I want to use a javamoney lib, I found two lib the below: javamoney/jsr354-api and javamoney/jsr354-ri in the github. What's the diffirence, thank you.
user3172755
  • 137
  • 1
  • 10
1
vote
1 answer

Is JSR-354 Money API ready for production usage?

Nowadays, i'm doing research about which data type would be proper for money/currency in Java 8. I've encountered JSR-354 specification for data types and operations on money/currency data. Reference implementation with its API is here:…
baybatu
  • 81
  • 8