Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for JSR-354 Money & Currency [SPR-12209] #16823

Closed
spring-issuemaster opened this issue Sep 17, 2014 · 7 comments

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

commented Sep 17, 2014

Juergen Hoeller opened SPR-12209 and commented

The JSR-354 Money & Currency API looks like a good fit for Spring's binding and formatting features, analogous to Spring 4.0's JSR-310 Date & Time support. JSR-354 comes with a JDK 8 based reference implementation that should be easy enough to support in Spring 4.2 already. The RI is currently in the 1.0 RC stages; it is expected that it'll be at 1.0 GA in time for the Spring Framework 4.2 GA release.


Reference URL: http://javamoney.github.io/

Issue Links:

  • #21560 Update documentation references to Number/Currency/PercentStyleFormatter
  • #12417 Currency support ("supersedes")

Referenced from: commits de893ad, 6c169bd

2 votes, 7 watchers

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 12, 2015

Juergen Hoeller commented

Introduced MonetaryAmountFormatter and CurrencyUnitFormatter, both registered by default in DefaultFormattingConversionService if the JSR-354 API is present on the classpath. Currently building against the JSR-354 API 1.0-RC3; to be upgraded to 1.0 GA in time for Spring Framework 4.2 RC1.

Any ideas for further JSR-354 support features, let me know. An initial pass only really revealed the need for the above formatters, with no binding-related features having been standardized beyond what we're doing there currently. In particular, there are no pre-defined formatting customizations; it all goes through the MonetaryAmountFormat SPI, with the need to pre-define custom formats under specific format names.

Juergen

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 12, 2015

Juergen Hoeller commented

It turns out that there are ways to make our common @NumberFormat annotation work with MonetaryAmount as well, based on some internal DecimalFormat adapting, so I'm implementing out-of-the-box support for this. Given the lack of fine-grained customization with the JSR-354 MonetaryAmountFormatter mechanism, this seems to be a worthwhile addition.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 13, 2015

Juergen Hoeller commented

Initial cut pushed to master now. Some TODOs remain to be revisited, in particular currency detection for @NumberFormat bindings.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 16, 2015

Elliot Huntington commented

It looks like this ticket is just for formatting. Is there any plan to create a hibernate custom user type to persist a MonetaryAmount?

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 16, 2015

Juergen Hoeller commented

Indeed, this ticket is primarily about binding and formatting, plus anything else we could be doing in Spring Framework itself.

Custom user types for Hibernate should rather be submitted to the Hibernate project... FWIW, we don't ship JSR-310 Date-Time adapters for Hibernate, Jackson etc either.

Juergen

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Apr 15, 2015

Chris Beams commented

FYI, here's a thread on the BitcoinJ mailing list in which adoption of JSR-354 is being discussed. It'll be nice for bitcoin-related apps to have first-class support in Spring for formatting and binding to these types. https://groups.google.com/d/msg/bitcoinj/vY61tUmZuso/aAnC-HefvU8J

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented May 20, 2015

Juergen Hoeller commented

Finally updated to the recently released JSR-354 API in its 1.0 GA form (adapted to the refactored lookup methods). Remaining parser TODOs addressed as well, with @NumberFormat-based parsing now detecting a currency code at the beginning or end of the given text value if the declared pattern includes the correspondong symbols.

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.