mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 22:44:49 +00:00
ICU-13060 One more tweak to CurrencyUsage override for backwards compatibility.
X-SVN-Rev: 39955
This commit is contained in:
parent
bd7655a38e
commit
6616bebf9f
3 changed files with 26 additions and 4 deletions
|
@ -167,13 +167,13 @@ public abstract class Rounder extends Format.BeforeFormat {
|
|||
// For backwards compatibility, minimum overrides maximum if the two conflict.
|
||||
// The following logic ensures that there is always a minimum of at least one digit.
|
||||
if (_minInt == 0 && _maxFrac != 0) {
|
||||
// Force a digit to the right of the decimal point.
|
||||
// Force a digit after the decimal point.
|
||||
minFrac = _minFrac <= 0 ? 1 : _minFrac;
|
||||
maxFrac = _maxFrac < 0 ? Integer.MAX_VALUE : _maxFrac < minFrac ? minFrac : _maxFrac;
|
||||
minInt = 0;
|
||||
maxInt = _maxInt < 0 ? Integer.MAX_VALUE : _maxInt;
|
||||
} else {
|
||||
// Force a digit to the left of the decimal point.
|
||||
// Force a digit before the decimal point.
|
||||
minFrac = _minFrac < 0 ? 0 : _minFrac;
|
||||
maxFrac = _maxFrac < 0 ? Integer.MAX_VALUE : _maxFrac < minFrac ? minFrac : _maxFrac;
|
||||
minInt = _minInt <= 0 ? 1 : _minInt;
|
||||
|
|
|
@ -258,8 +258,16 @@ public class CurrencyFormat {
|
|||
|
||||
if (_currencyUsage == null && (_minFrac >= 0 || _maxFrac >= 0)) {
|
||||
// User override of fraction length
|
||||
destination.setMinimumFractionDigits(_minFrac);
|
||||
destination.setMaximumFractionDigits(_maxFrac);
|
||||
if (_minFrac < 0) {
|
||||
destination.setMinimumFractionDigits(fractionDigits < _maxFrac ? fractionDigits : _maxFrac);
|
||||
destination.setMaximumFractionDigits(_maxFrac);
|
||||
} else if (_maxFrac < 0) {
|
||||
destination.setMinimumFractionDigits(_minFrac);
|
||||
destination.setMaximumFractionDigits(fractionDigits > _minFrac ? fractionDigits : _minFrac);
|
||||
} else {
|
||||
destination.setMinimumFractionDigits(_minFrac);
|
||||
destination.setMaximumFractionDigits(_maxFrac);
|
||||
}
|
||||
} else {
|
||||
// Currency rounding
|
||||
destination.setMinimumFractionDigits(fractionDigits);
|
||||
|
|
|
@ -5202,6 +5202,20 @@ public class NumberFormatTest extends TestFmwk {
|
|||
expect2(df, 1234, "1,234");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCurrencyUsageFractionOverrides() {
|
||||
NumberFormat df = DecimalFormat.getCurrencyInstance(ULocale.US);
|
||||
expect2(df, 35.0, "$35.00");
|
||||
df.setMinimumFractionDigits(3);
|
||||
expect2(df, 35.0, "$35.000");
|
||||
df.setMaximumFractionDigits(3);
|
||||
expect2(df, 35.0, "$35.000");
|
||||
df.setMinimumFractionDigits(-1);
|
||||
expect2(df, 35.0, "$35.00");
|
||||
df.setMaximumFractionDigits(1);
|
||||
expect2(df, 35.0, "$35.0");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSignificantDigitsMode() {
|
||||
String[][] allExpected = {
|
||||
|
|
Loading…
Add table
Reference in a new issue