diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormatSymbols.java b/icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormatSymbols.java index 07e812bcd2a..8daac032104 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormatSymbols.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormatSymbols.java @@ -185,8 +185,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable { /** * Sets the character used for zero. *

- * Note: When the specified zeroDigit is a Unicode decimal digit character - * (category:Nd) and the number value is 0, then this method propagate digit 1 to + * Note: This method propagates digit 1 to * digit 9 by incrementing code point one by one. * * @param zeroDigit the zero character. @@ -205,15 +204,11 @@ public class DecimalFormatSymbols implements Cloneable, Serializable { digitStrings[0] = String.valueOf(zeroDigit); digits[0] = zeroDigit; - // Propagate digit 1 - 9 only when the input zeroDigit is a - // Unicode number and its integer value is 0. - - if (Character.digit(zeroDigit, 10) == 0) { - for (int i = 1; i < 10; i++) { - char d = (char)(zeroDigit + i); - digitStrings[i] = String.valueOf(d); - digits[i] = d; - } + // Always propagate to digits 1-9 for JDK and ICU4C consistency. + for (int i = 1; i < 10; i++) { + char d = (char)(zeroDigit + i); + digitStrings[i] = String.valueOf(d); + digits[i] = d; } } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatSymbols.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatSymbols.java index 56688a236b9..2180a789c6f 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatSymbols.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatSymbols.java @@ -24,6 +24,7 @@ import java.util.Locale; import org.junit.Test; +import com.ibm.icu.text.DecimalFormat; import com.ibm.icu.text.DecimalFormatSymbols; import com.ibm.icu.util.Currency; import com.ibm.icu.util.ULocale; @@ -260,6 +261,24 @@ public class IntlTestDecimalFormatSymbols extends com.ibm.icu.dev.test.TestFmwk } } + @Test + public void testPropagateZeroDigit() { + DecimalFormatSymbols dfs = new DecimalFormatSymbols(); + dfs.setZeroDigit('\u1040'); + DecimalFormat df = new DecimalFormat("0"); + df.setDecimalFormatSymbols(dfs); + assertEquals("Should propagate char with number property zero", + '\u1041', dfs.getDigits()[1]); + assertEquals("Should propagate char with number property zero", + "\u1044\u1040\u1041\u1042\u1043", df.format(40123)); + dfs.setZeroDigit('a'); + df.setDecimalFormatSymbols(dfs); + assertEquals("Should propagate char WITHOUT number property zero", + 'b', dfs.getDigits()[1]); + assertEquals("Should propagate char WITHOUT number property zero", + "eabcd", df.format(40123)); + } + @Test public void testDigitSymbols() { final char defZero = '0';