/** * Sets the maximum number of digits allowed in the fraction portion of a number. This * override limits the fraction digit count to 340. * * @see NumberFormat#setMaximumFractionDigits * @stable ICU 2.0 */ public void setMaximumFractionDigits(int newValue) { super.setMaximumFractionDigits(newValue); }
/** * Sets the maximum number of digits allowed in the fraction portion of a number. This * override limits the fraction digit count to 340. * * @see NumberFormat#setMaximumFractionDigits * @stable ICU 2.0 */ public void setMaximumFractionDigits(int newValue) { super.setMaximumFractionDigits(newValue); }
@Override public void setMaximumFractionDigits(int newValue) { fIcuNfmt.setMaximumFractionDigits(newValue); }
private void _setMaximumFractionDigits(int newValue) { super.setMaximumFractionDigits(Math.min(newValue, DOUBLE_FRACTION_DIGITS)); }
/** Formats a double into a properly formatted string, with two decimals, based on Locale * @param amount The amount double to be formatted * @param locale The Locale used to format the number * @return A String with the formatted amount */ // This method should be used in place of formatPrice because it is locale aware. public static String formatAmount(double amount, Locale locale) { com.ibm.icu.text.NumberFormat nf = com.ibm.icu.text.NumberFormat.getInstance(locale); nf.setMinimumFractionDigits(2); nf.setMaximumFractionDigits(2); return nf.format(amount); }
/** Formats a double into a properly formatted currency string based on isoCode and Locale * @param price The price double to be formatted * @param isoCode the currency ISO code * @param locale The Locale used to format the number * @param maximumFractionDigits The maximum number of fraction digits used; if set to -1 than the default value for the locale is used * @return A String with the formatted price */ public static String formatCurrency(double price, String isoCode, Locale locale, int maximumFractionDigits) { com.ibm.icu.text.NumberFormat nf = com.ibm.icu.text.NumberFormat.getCurrencyInstance(locale); if (isoCode != null && isoCode.length() > 1) { nf.setCurrency(com.ibm.icu.util.Currency.getInstance(isoCode)); } else { if (Debug.verboseOn()) { Debug.logVerbose("No isoCode specified to format currency value:" + price, module); } } if (maximumFractionDigits >= 0) { nf.setMaximumFractionDigits(maximumFractionDigits); } return nf.format(price); }
numberFormat.setMaximumFractionDigits(maxFractionDigits);
numberFormat.setMaximumFractionDigits(maxFractionDigits);
intFormat.setMaximumFractionDigits(0); intFormat.setMinimumFractionDigits(0); intFormat.setRoundingMode(BigDecimal.ROUND_DOWN);