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 formatter formats #38

Open
yarrouye opened this issue Mar 17, 2014 · 5 comments
Open

Support for formatter formats #38

yarrouye opened this issue Mar 17, 2014 · 5 comments

Comments

@yarrouye
Copy link

Hi,

I was looking at the source for Joda Money as it has no way to get a formatter for a specific locale, and noticed a couple commented out functions in MoneyFormatterBuilder taking patterns... Is that something you are working on and is coming up, or something that was abandoned?

@jodastephen
Copy link
Member

Its something I was too busy to finish. I think patterns like that would be a good feature.

@yarrouye
Copy link
Author

I agree. Is this something you're going to get back to?

I would probably want to use the standard notation for patterns (i.e.
###.## and using the currency symbol etc. rather than or at least in
addition to a verbose format with {$someName}" which may be what you had in
mind with your singletons? And I also think that part of localization
should also support for proper use of separators between amounts and
currencies.

I would actually have put those in a MoneyFormat class, similar to
DateTimeFormat in Joda Time. What do you think? I may give it a shout... if
so I'd appreciate understanding your thinking behind what you had started.

On Mon, Mar 17, 2014 at 3:10 PM, Stephen Colebourne <
notifications@github.com> wrote:

Its something I was too bus to finish. I think patterns like that would be
a good feature.


Reply to this email directly or view it on GitHubhttps://github.com//issues/38#issuecomment-37877343
.

@jodastephen
Copy link
Member

I think a combination of ### type patterns and $ type patterns would be useful. Feel free to propose something, I'm not going to get to work on it anytime soon.

In general, Joda-Time tends to try to be reasonably compatible with JDK patterns, so I'd expect money to do the same. No need to slavishly follow JDK mistakes though.

@yarrouye
Copy link
Author

I agree re: compatibility. The main issue I see right now with the Joda
Money formatter (at a VERY quick glance) is that it treats the currency and
the amount as two very separate things, when really they are not. For
example, the default way to format "-123.33 in USD" in Java and other
frameworks for the Locale.US locale is "($123.33)" where the parenthesis
come from the fact that the amount is negative, and the rest is regular
currency formatting. Your pattern APIs seem to have that going on, but I do
not know if those would be easy to map to your singletons (I guess one
could always write a singleton that always write abs(amount) and use that
appropriately when mapping patterns).

The Printer/Parser concept works well outside of the builder in any case; I
was able to whip out a MoneyFormat.forLocale(Locale) that returned a
formatter implementing both the printer and parser interfaces using the
JDK's DecimalFormat class in very few lines of codes. However, I put this
in my own libraries rather than yours as I believe the latter would require
a grounds up implementation of the code; and I haven't found a good public
source of currency formats I could bring into such code...

On Mon, Mar 17, 2014 at 3:24 PM, Stephen Colebourne <
notifications@github.com> wrote:

I think a combination of ### type patterns and $ type patterns would be
useful. Feel free to propose something, I'm not going to get to work on it
anytime soon.

In general, Joda-Time tends to try to be reasonably compatible with JDK
patterns, so I'd expect money to do the same. No need to slavishly follow
JDK mistakes though.


Reply to this email directly or view it on GitHubhttps://github.com//issues/38#issuecomment-37878674
.

@jodastephen
Copy link
Member

Just to note that the elements within the formatter do not have to be singletons, they can be private immutable inner classes with state. See Joda-Time/JSR-310 formatter for examples of this.

Currency/Money data is present in CLDR, which is where Oracle/JDK gets its data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants