-
-
Notifications
You must be signed in to change notification settings - Fork 101
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
Money.toString() and Money.parse(…) not symmetric anymore #357
Comments
Tweaked the implementation of MonetaryAmountAttributeConverter to workaround JavaMoney/jsr354-ri#357, as in 1.4 the toString() method returns a formatted value. We now extract currency code and numeric value explicitly ourselves.
Can you explain why you mentioned |
In the production code, I work with a |
Also here please be patient until https://issues.sonatype.org/browse/OSSRH-68317 can be resolved by Sonatype because for some totally unknown and strange reason the same Sonatype user which never had problems to sync from Bintray while that was still around suddenly fails to deploy snapshots directly. Hope they can fix that soon, because no other "technical" or personal account I use for other projects and JSRs ever failed, only the "JavaMoney" one. |
Tweaked the implementation of MonetaryAmountAttributeConverter to workaround JavaMoney/jsr354-ri#357, as in 1.4 the toString() method returns a formatted value. We now extract currency code and numeric value explicitly ourselves.
Tweaked the implementation of MonetaryAmountAttributeConverter to workaround JavaMoney/jsr354-ri#357, as in 1.4 the toString() method returns a formatted value. We now extract currency code and numeric value explicitly ourselves. [This is a cherry-pick of e99e67b in main, see issue #345.]
Tweaked the implementation of MonetaryAmountAttributeConverter to workaround JavaMoney/jsr354-ri#357, as in 1.4 the toString() method returns a formatted value. We now extract currency code and numeric value explicitly ourselves. [This is a cherry-pick of e99e67b in main, see issue #345.]
I did reopen that, because I found what caused it, starting with at least 1.4.0 or even before, Anatole had hardcoded the scale of It would be more or less a one-liner to use the scale of the Therefore I recommend making this customizable, but leaving the default number as 2 digits, a bit similar to overriding the default format as such via @odrotbohm, @otaviojava what do you think? And then we must document such backward-incompatible changes, giving users enough notice to migrate their code. If that works here, and we can confirm, that #370 only affects a few tests but does not mess the runtime behavior (because the normal |
There are two parts to this problem:
|
Actually the majority of test failures were pretty much the same, so avoiding the round-down plus an adjustment of the scale that also takes the Each of the three test cases now have a @odrotbohm, @otaviojava please review. |
Did not hear anything by either one, so I assume that is resolved. |
Hey, I just noticed, after upgrading from 1.4.2, that the previously applied default rounding to a fixed scale=2 in toString() is not applied anymore. We heavily rely on this, e.g. whenever we serialize a Money value to JSON. So it's a quite invasive breaking change. Is there a way to apply this default rounding? I stumbled upon MonetaryConfig, but found no usable documentation on how to best do this in SpringBoot. |
The hardcoded scale for toString() was what had to be fixed here, so adding it back would only be possible as an optional property, Please create an enhancement request here, and we'll see, if we could add something into
prints "EUR 1234567.30". |
@stefanzilske I saw #364 had been around for some time, we did not really plan to do this (especially the desire to just print "a" or something) until a much later version, but it seems fair to "hijack" it for your particular requirement and customize both I linked them this way, but it would be nice to mention a few words about the requirement in #364 if you can. Btw, there are currently no plans to configure Moneta via the SpringBoot |
Similarly to #319, the change made for #307 breaks print/parse symmetry without any kind of formatting involved. Assume you want to serialize (generally, not in a Java serialize way) a
Money
viatoString()
to eventually recreate it viaMoney.parse(…)
. Up until version 1.4, the following worked:This now fails with "Expected is <EUR 1.23> but was <EUR 1.23>". The reason for this is that as of 1.4 (#307)
toString()
now applies some default formatting, which I think is not only wrong, it's also highly misleading as you can see from the assertion message, as the source value is not 1.23, but 1.2345.The text was updated successfully, but these errors were encountered: