With a recent change in UI5 version 1.130, we corrected the formatting of decimal places for currencies.
If no decimals are provided in the oFormatOptions of the sap.ui.core.format.NumberFormat.getCurrencyInstance API (either via the direct format option decimals or via currency customizing as specified by the format option customCurrencies), the given value is formatted with the decimals value defined by the CLDR standard.
Prior to this change, applications may have defined currency formats, which relied on the maxFractionDigits format option to specify the number of decimal places. This is incorrect usage, as the maxFractionDigits parameter is meant to define the maximum but not the actual number of decimals.
With our change established, this behavior has changed. Now the semantics of the maxFractionDigits/minFractionDigits format options is correctly interpreted for currency formats, namely as the maximum and minimum number of permitted decimals.
For the en locale, the formatted result has 2 decimal places:
As 2 < 3, this is the correct result. The output does not exceed the maximum number of decimal places in this format, and the currency is formatted according to the locale-specific standard.
This change also affects the formatting of currencies with fewer decimal places than expected by their CLDR configurations.
In the prior behavior, the number of decimal places remained the same if the number given contained more decimal places than defined by the minFractionDigits option.
With the new change in place, this is not the case anymore as the CLDR defines the number of decimal places for the USD currency in the given locale as 2. Therefore, a zero is padded at the end.
The new behavior of tests and applications depends on the application setup. If the currency formats either use currency customizing where decimals are defined for all currencies or define a decimals format option for their binding, the behavior stays the same.
If, on the other hand, an application relies on the maxFractionDigits option to always determine the number of decimal places on its currency formats, this cannot be assured anymore. Only if maxFractionDigits < decimals may the maxFractionDigits option still be used to format the output.
Thus, it is up to the application developer to decide, between one of the following alternatives:
Alternative 1 (The application should continue to determine the number of decimal places for currencies itself) - The application has to use the decimals format option instead of the maxFractionDigits option for that.
For more information regarding the format options available for our NumberFormat.getCurrencyInstance API, see: sap.ui.core.format.NumberFormat.getCurrencyInstance
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
25 | |
17 | |
16 | |
11 | |
8 | |
8 | |
7 | |
7 | |
6 | |
6 |