Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 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.g. Chinese Yuan Renminbi (Offshore) CNH which has no official ISO recognition, but it's well known.

Thanks,

like image 970
ha9u63ar Avatar asked Oct 25 '18 22:10

ha9u63ar


2 Answers

Thanks for the input so far. As one of the designated new Maintenance Leads (also see Transfer Ballot) allow me to give a more formal answer from our side.

As you may know, Oracle has removed many features from Java 11, JavaFX probably the most prominent "victim" which was released into an Open Source ecosystem backed by a couple of other companies, a few Oracle employees and other members of the community.

JavaMoney, the wider project behind JSR 354 and some of its extensions has always played a similar role. After the Transfer Ballot, there is one company (Trivadis) and 2 Individual EG Members as Maintenance Leads. Plus a lot of others contributed extensions including large names like Red Hat or Zalando. So JSR 354 and a likely follow-up (aka JavaMoney 2.x) compliment Java SE similar to how OpenJFX, Apache NetBeans or other Open Community efforts do without being an integral part of the JDK. I spoke to an Oracle employee familiar with OpenJDK at Eclipse Community Day and he confirmed, this was also in Oracle's interest to focus on core features of the JDK while other vendors and communities provide additional features around it. Plus with a future Money JSR under the "iterative" release plan developed for the JDK itself, but open to an other JSR we plan to offer regular releases at a pace that matches the needs of the community. Should say Italy or another country lose its place in the Eurozone due to excessive debt or another "Brexit" like situation happen, then currencies for those countries will change. And an independent Money JSR can immediately respond to that by providing the necessary changes without having to wait for the JDK.

like image 91
Werner Keil Avatar answered Nov 19 '22 09:11

Werner Keil


  1. Initially JavaMoney was targeted to be included into JDK but then it was decided to make it as JavaEE spec. As you may know starting from JDK11 the JavaEE classes aren't a part of JDK and they should be installed as any other usual dependency i.e. via Maven.
  2. Yes, you can add any custom currencies and this is supported out of the box. You need to add an instance of CurrencyProviderSpi as described in the tutorial Registering Custom Currencies.
like image 44
Sergey Ponomarev Avatar answered Nov 19 '22 10:11

Sergey Ponomarev