/** * Formats the specified number according to the specified rule set. * @param number The number to format. * @param ruleSet The name of the rule set to format the number with. * This must be the name of a valid public rule set for this formatter. * @return A textual representation of the number. * @stable ICU 2.0 */ public String format(double number, String ruleSet) throws IllegalArgumentException { if (ruleSet.startsWith("%%")) { throw new IllegalArgumentException("Can't use internal rule set"); } return adjustForContext(format(number, findRuleSet(ruleSet))); }
/** * Formats the specified number according to the specified rule set. * (If the specified rule set specifies a master ["x.0"] rule, this function * ignores it. Convert the number to a double first if you ned it.) This * function preserves all the precision in the long-- it doesn't convert it * to a double. * @param number The number to format. * @param ruleSet The name of the rule set to format the number with. * This must be the name of a valid public rule set for this formatter. * @return A textual representation of the number. * @stable ICU 2.0 */ public String format(long number, String ruleSet) throws IllegalArgumentException { if (ruleSet.startsWith("%%")) { throw new IllegalArgumentException("Can't use internal rule set"); } return adjustForContext(format(number, findRuleSet(ruleSet))); }
/** * Formats the specified number using the formatter's default rule set. * (The default rule set is the last public rule set defined in the description.) * @param number The number to format. * @param toAppendTo A StringBuffer that the result should be appended to. * @param ignore This function doesn't examine or update the field position. * @return toAppendTo * @stable ICU 2.0 */ @Override public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition ignore) { // this is one of the inherited format() methods. Since it doesn't // have a way to select the rule set to use, it just uses the // default one // Note, the BigInteger/BigDecimal methods below currently go through this. if (toAppendTo.length() == 0) { toAppendTo.append(adjustForContext(format(number, defaultRuleSet))); } else { // appending to other text, don't capitalize toAppendTo.append(format(number, defaultRuleSet)); } return toAppendTo; }
/** * Formats the specified number using the formatter's default rule set. * (The default rule set is the last public rule set defined in the description.) * (If the specified rule set specifies a master ["x.0"] rule, this function * ignores it. Convert the number to a double first if you ned it.) This * function preserves all the precision in the long-- it doesn't convert it * to a double. * @param number The number to format. * @param toAppendTo A StringBuffer that the result should be appended to. * @param ignore This function doesn't examine or update the field position. * @return toAppendTo * @stable ICU 2.0 */ @Override public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition ignore) { // this is one of the inherited format() methods. Since it doesn't // have a way to select the rule set to use, it just uses the // default one if (toAppendTo.length() == 0) { toAppendTo.append(adjustForContext(format(number, defaultRuleSet))); } else { // appending to other text, don't capitalize toAppendTo.append(format(number, defaultRuleSet)); } return toAppendTo; }