Skip to main content

[JSR-354] Re: Denominations and Fractions

  • From: Werner Keil <werner.keil@...>
  • To: jcurrency_mail@...
  • Subject: [JSR-354] Re: Denominations and Fractions
  • Date: Tue, 16 Apr 2013 15:18:31 +0200

Besides, while getDisplayName() of java.util.Currency or CurrencyUnit usually shows the name like "Dollar" or "US Dollar", "Franken" (in German) or similar, the fractions are only represented as far as fraction digits, but "Cent", "Penny" or "Rappen" AFAIK is not supported.

Should we go into the area of fraction units similar to MajorPart or MinorPart of the MonetaryAmount
(which currently is integral part of the Platform level RI, thus proposed to become part of the JDK some day) then questions like Simon raised it or naming such MinorPart (the Currency technically isn't even correct there, if you take the MinorPart according to JavaDoc

This returns the monetary amount in terms of the minor units of the
* currency, truncating the amount if necessary. For example, 'EUR 2.35'
* will return 235, and 'BHD -1.345' will return -1345.
the value is returned correctly, but it'll be "235 Euro Cents", not "Euro", I don't think the MinorPart implemention covers that yet, thus it seems incorrect in that case

Whether or not we need possible coin sizes, multiples or submultiples for each currency, I can't tell, alongside many rather commonly used features like Holiday/Workday dropped from 310 or never taken into consideration, I'm tempted to say, it's "Nice to Have", maybe even in the area of "Ext" which is likely to be factored out of the actual Spec and moved to a separate repository, see 310 or its backport on Github, too.

If we keep MinorPart, then we must properly name and identify the fraction, most likely in the sense of a CurrencyUnit (just like 310 has multiples and submultiples as TemporalUnit) with name and symbol, usually no code, or sharing the code from its parent (or does "Rappen" or "Cent" have a separate ISO Code?)

Regards,
Werner

On Tue, Apr 16, 2013 at 3:04 PM, Werner Keil <werner.keil@...> wrote:
That would be closest to what JSR 310 has in places like http://download.java.net/jdk8/docs/api/java/time/temporal/ChronoUnit.html based on TemporalUnit which can be implemented differently.

A TemporalAmount of "10 days, 5 minutes, 30 milliseconds  therefore has a set of 3 TemporalUnit items DAYS, MINUTES and MILLIS.

Calling the enum standard method values() gives you all possible TemporalUnits for such implementation.

Not sure, if we'd want to do that as enum, after all currency data so far comes from a binary file called currency.data in the JRE, don't think there are significant hard coded definitions other than that, so adding new currency data to both standalone and JDK/JRE level implementations should be compatible with this kind of information, or we'll have to define and provide an alternate data source for all currencies to hold that.

Regards,
Werner

On Tue, Apr 16, 2013 at 2:41 PM, Simon Martinelli <simon.martinelli@...> wrote:
Hi all,

In commerce applications we often need to know what denominations and fractions a currency unit has. Like in CHF denonminations (1000, 200, 100, 50, 20, 10) and fractions (50, 20, 10, 5) 

We need that to do some validation on the cash desk. To check if the given amount that the cashier enters is valid.

Do we plan to implement such things?

Regard, Simon



[JSR-354] Denominations and Fractions

Simon Martinelli 04/16/2013

[JSR-354] Re: Denominations and Fractions

Tresch Anatole (KFSC 225) 04/16/2013

[JSR-354] Re: Denominations and Fractions

Werner Keil 04/16/2013

[JSR-354] Re: Denominations and Fractions

Werner Keil 04/16/2013

[JSR-354] Re: Denominations and Fractions

Werner Keil 04/16/2013

[JSR-354] Re: Denominations and Fractions

Werner Keil 04/16/2013

[JSR-354] Re: Denominations and Fractions

Tresch Anatole (KFSC 225) 04/16/2013

[JSR-354] Re: Denominations and Fractions

Simon Martinelli 04/16/2013

[JSR-354] Re: Denominations and Fractions

Werner Keil 04/16/2013

[JSR-354] Re: Denominations and Fractions

Werner Keil 04/16/2013

[JSR-354] Re: Denominations and Fractions

Werner Keil 04/16/2013

[JSR-354] Re: Denominations and Fractions

Werner Keil 04/16/2013
 
 
Close
loading
Please Confirm
Close