/**
* @internal
- * @deprecated This API is ICU internal only.
+ * @deprecated This API is ICU internal only. Use {@link #populateFieldPosition} or
+ * {@link #getFieldIterator} for similar functionality.
*/
@Deprecated
public String getPrefix() {
NumberStringBuilder temp = new NumberStringBuilder();
- int length = micros.modOuter.apply(temp, 0, 0);
- length += micros.modMiddle.apply(temp, 0, length);
- /* length += */ micros.modInner.apply(temp, 0, length);
- int prefixLength = micros.modOuter.getPrefixLength() + micros.modMiddle.getPrefixLength()
- + micros.modInner.getPrefixLength();
+ // #13453: DecimalFormat wants the affixes from the pattern only (modMiddle).
+ micros.modMiddle.apply(temp, 0, 0);
+ int prefixLength = micros.modMiddle.getPrefixLength();
return temp.subSequence(0, prefixLength).toString();
}
/**
* @internal
- * @deprecated This API is ICU internal only.
+ * @deprecated This API is ICU internal only. Use {@link #populateFieldPosition} or
+ * {@link #getFieldIterator} for similar functionality.
*/
@Deprecated
public String getSuffix() {
NumberStringBuilder temp = new NumberStringBuilder();
- int length = micros.modOuter.apply(temp, 0, 0);
- length += micros.modMiddle.apply(temp, 0, length);
- length += micros.modInner.apply(temp, 0, length);
- int prefixLength = micros.modOuter.getPrefixLength() + micros.modMiddle.getPrefixLength()
- + micros.modInner.getPrefixLength();
+ // #13453: DecimalFormat wants the affixes from the pattern only (modMiddle).
+ int length = micros.modMiddle.apply(temp, 0, 0);
+ int prefixLength = micros.modMiddle.getPrefixLength();
return temp.subSequence(prefixLength, length).toString();
}
// #equals() or #hashCode() on them directly.
FormattedNumber _other = (FormattedNumber) other;
return Arrays.equals(nsb.toCharArray(), _other.nsb.toCharArray())
- ^ Arrays.equals(nsb.toFieldArray(), _other.nsb.toFieldArray())
- ^ fq.toBigDecimal().equals(_other.fq.toBigDecimal());
+ && Arrays.equals(nsb.toFieldArray(), _other.nsb.toFieldArray())
+ && fq.toBigDecimal().equals(_other.fq.toBigDecimal());
}
}
\ No newline at end of file
assertEquals("Grouping should be off", false, df.isGroupingUsed());
}
+ @Test
+ public void Test13453_AffixContent() {
+ DecimalFormat df = (DecimalFormat) DecimalFormat.getScientificInstance();
+ assertEquals("Scientific should NOT be included", "", df.getPositiveSuffix());
+
+ df = CompactDecimalFormat.getInstance(ULocale.ENGLISH, CompactDecimalFormat.CompactStyle.SHORT);
+ assertEquals("Compact should NOT be included", "", df.getPositiveSuffix());
+
+ df = (DecimalFormat) DecimalFormat.getInstance(NumberFormat.ISOCURRENCYSTYLE);
+ df.setCurrency(Currency.getInstance("GBP"));
+ assertEquals("ISO currency SHOULD be included", "GBP", df.getPositivePrefix());
+
+ df = (DecimalFormat) DecimalFormat.getInstance(NumberFormat.PLURALCURRENCYSTYLE);
+ df.setCurrency(Currency.getInstance("GBP"));
+ assertEquals("Plural name SHOULD be included", " British pounds", df.getPositiveSuffix());
+ }
+
@Test
public void Test11035_FormatCurrencyAmount() {
double amount = 12345.67;