You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a use case where i present many amounts all of the same currency on one table. I want to remove the currency code from the toString which is used by my templating framework. The ui will just indicate that the entire table is in one currency.
I've patched the RI to allow just "a" as the format string, which does what I need.
The text was updated successfully, but these errors were encountered:
Yes sure - but you won't like it ;), here it is. Allows you to specify just 'a' as the format:
Index: moneta-core/src/main/java/org/javamoney/moneta/ToStringMonetaryAmountFormat.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/moneta-core/src/main/java/org/javamoney/moneta/ToStringMonetaryAmountFormat.java b/moneta-core/src/main/java/org/javamoney/moneta/ToStringMonetaryAmountFormat.java
--- a/moneta-core/src/main/java/org/javamoney/moneta/ToStringMonetaryAmountFormat.java (revision cfcc7e42ab89659cd5f8222e1fb3ff78aedaf806)
+++ b/moneta-core/src/main/java/org/javamoney/moneta/ToStringMonetaryAmountFormat.java (revision b8e36f54f4f9effa19186cf54c01a65a5474b21c)
@@ -104,6 +104,8 @@
case "a c":
case "a-c":
return dec.toPlainString() + " " + m.getCurrency().getCurrencyCode();
+ case "a":
+ return dec.toPlainString();
case "currency-amount":
case "currency amount":
case "ca":
Although it's probably faster to wrap Money in your own class, and use Lombok's @Delegate annotation and then override the toString formatter. That's what I ended up doing as there were other things I needed to change too.
keilw
changed the title
Allow more customisation to toString formats - specifically dropping the currency code
Allow more customisation of toString formats - specifically dropping the currency code
Feb 20, 2024
I have a use case where i present many amounts all of the same currency on one table. I want to remove the currency code from the toString which is used by my templating framework. The ui will just indicate that the entire table is in one currency.
I've patched the RI to allow just "a" as the format string, which does what I need.
The text was updated successfully, but these errors were encountered: