/** * Formats a BigInteger number. * * @stable ICU 2.0 */ public StringBuffer format(BigInteger number, StringBuffer result, FieldPosition fieldPosition) { return super.format(number, result, fieldPosition); }
/** * Formats a BigDecimal number. * * @stable ICU 2.0 */ public StringBuffer format(java.math.BigDecimal number, StringBuffer result, FieldPosition fieldPosition) { return super.format(number, result, fieldPosition); }
/** * {@inheritDoc} * @stable ICU 2.0 */ public StringBuffer format(double number, StringBuffer result, FieldPosition fieldPosition) { return super.format(number, result, fieldPosition); }
/** * @stable ICU 2.0 */ // [Spark/CDL] Delegate to format_long_StringBuffer_FieldPosition_boolean public StringBuffer format(long number, StringBuffer result, FieldPosition fieldPosition) { return super.format(number, result, fieldPosition); }
/** * Formats a BigDecimal number. * * @stable ICU 2.0 */ public StringBuffer format(BigDecimal number, StringBuffer result, FieldPosition fieldPosition) { return super.format(number, result, fieldPosition); }
/** * Formats a BigInteger number. * * @stable ICU 2.0 */ public StringBuffer format(BigInteger number, StringBuffer result, FieldPosition fieldPosition) { return super.format(number, result, fieldPosition); }
/** * {@inheritDoc} * @stable ICU 2.0 */ public StringBuffer format(double number, StringBuffer result, FieldPosition fieldPosition) { return super.format(number, result, fieldPosition); }
/** * {@icu} Convenience method to format an ICU BigDecimal. * @stable ICU 2.0 */ public final String format(com.ibm.icu.math.BigDecimal number) { return format(number, new StringBuffer(), new FieldPosition(0)).toString(); }
@Override public String convert(Object fromObject) { // Null is allowed when the type is not primitve. if (fromObject == null && !primitive) { return ""; //$NON-NLS-1$ } if (!boxedType.isInstance(fromObject)) { throw new IllegalArgumentException( "'fromObject' is not of type [" + boxedType + "]."); //$NON-NLS-1$//$NON-NLS-2$ } return numberFormat.format(((Number) fromObject).longValue()); }
/** * Convenience method to format a BigDecimal. * @stable ICU 2.0 */ public final String format(java.math.BigDecimal number) { return format(number, new StringBuffer(), new FieldPosition(0)).toString(); }
/** * {@icu} Convenience method to format a BigInteger. * @stable ICU 2.0 */ public final String format(BigInteger number) { return format(number, new StringBuffer(), new FieldPosition(0)).toString(); }
@Override public Object convert(Object fromObject) { // Null is allowed when the type is not primitve. if (fromObject == null && !primitive) { return ""; //$NON-NLS-1$ } if (!boxedType.isInstance(fromObject)) { throw new IllegalArgumentException( "'fromObject' is not of type [" + boxedType + "]."); //$NON-NLS-1$//$NON-NLS-2$ } return numberFormat.format(((Number) fromObject).longValue()); }
@Override public String formatDecimal(Number value) { return getNumberFormat().format(value); }
public String call() throws Exception { return context.get().getRuleBasedNumberFormat(RuleBasedNumberFormat.DURATION).format(value); } }, Locale.ENGLISH);
/** Formats a double into a properly spelled out number string 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 number */ public static String formatSpelledOutAmount(double amount, Locale locale) { com.ibm.icu.text.NumberFormat nf = new com.ibm.icu.text.RuleBasedNumberFormat(locale, com.ibm.icu.text.RuleBasedNumberFormat.SPELLOUT); return nf.format(amount); }
/** * Override Format.format(). * @see java.text.Format#format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition) */ public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos) { if (!(obj instanceof CurrencyAmount)) { throw new IllegalArgumentException("Invalid type: " + obj.getClass().getName()); } CurrencyAmount currency = (CurrencyAmount) obj; fmt.setCurrency(currency.getCurrency()); return fmt.format(currency.getNumber(), toAppendTo, pos); }
@Override public String formatNumber(String locale, Number number) { ULocale closestLocale = localeService.getClosestULocale(locale); NumberFormat nf = NumberFormat.getInstance(closestLocale); return nf.format(number); }
@Override public String formatNumber(String locale, Number number) { ULocale closestLocale = findClosestULocale(locale); NumberFormat nf = NumberFormat.getInstance(closestLocale); return nf.format(number); }
/** * Formats a number with the specified minimum and maximum number of digits. * @stable ICU 2.0 */ protected String zeroPaddingNumber(long value, int minDigits, int maxDigits) { numberFormat.setMinimumIntegerDigits(minDigits); numberFormat.setMaximumIntegerDigits(maxDigits); return numberFormat.format(value); }
/** 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); }