478 * <p> |
478 * <p> |
479 * This implementation uses the maximum precision permitted. |
479 * This implementation uses the maximum precision permitted. |
480 * @param number the number to format |
480 * @param number the number to format |
481 * @param toAppendTo the <code>StringBuffer</code> to which the formatted |
481 * @param toAppendTo the <code>StringBuffer</code> to which the formatted |
482 * text is to be appended |
482 * text is to be appended |
483 * @param pos On input: an alignment field, if desired. |
483 * @param pos keeps track on the position of the field within the |
484 * On output: the offsets of the alignment field. |
484 * returned string. For example, for formatting a number |
|
485 * {@code 1234567.89} in {@code Locale.US} locale, |
|
486 * if the given {@code fieldPosition} is |
|
487 * {@link NumberFormat#INTEGER_FIELD}, the begin index |
|
488 * and end index of {@code fieldPosition} will be set |
|
489 * to 0 and 9, respectively for the output string |
|
490 * {@code 1,234,567.89}. |
485 * @return the value passed in as <code>toAppendTo</code> |
491 * @return the value passed in as <code>toAppendTo</code> |
486 * @exception IllegalArgumentException if <code>number</code> is |
492 * @exception IllegalArgumentException if <code>number</code> is |
487 * null or not an instance of <code>Number</code>. |
493 * null or not an instance of <code>Number</code>. |
488 * @exception NullPointerException if <code>toAppendTo</code> or |
494 * @exception NullPointerException if <code>toAppendTo</code> or |
489 * <code>pos</code> is null |
495 * <code>pos</code> is null |
515 |
521 |
516 /** |
522 /** |
517 * Formats a double to produce a string. |
523 * Formats a double to produce a string. |
518 * @param number The double to format |
524 * @param number The double to format |
519 * @param result where the text is to be appended |
525 * @param result where the text is to be appended |
520 * @param fieldPosition On input: an alignment field, if desired. |
526 * @param fieldPosition keeps track on the position of the field within |
521 * On output: the offsets of the alignment field. |
527 * the returned string. For example, for formatting |
|
528 * a number {@code 1234567.89} in {@code Locale.US} |
|
529 * locale, if the given {@code fieldPosition} is |
|
530 * {@link NumberFormat#INTEGER_FIELD}, the begin index |
|
531 * and end index of {@code fieldPosition} will be set |
|
532 * to 0 and 9, respectively for the output string |
|
533 * {@code 1,234,567.89}. |
522 * @exception NullPointerException if {@code result} or |
534 * @exception NullPointerException if {@code result} or |
523 * {@code fieldPosition} is {@code null} |
535 * {@code fieldPosition} is {@code null} |
524 * @exception ArithmeticException if rounding is needed with rounding |
536 * @exception ArithmeticException if rounding is needed with rounding |
525 * mode being set to RoundingMode.UNNECESSARY |
537 * mode being set to RoundingMode.UNNECESSARY |
526 * @return The formatted number string |
538 * @return The formatted number string |
635 |
647 |
636 /** |
648 /** |
637 * Format a long to produce a string. |
649 * Format a long to produce a string. |
638 * @param number The long to format |
650 * @param number The long to format |
639 * @param result where the text is to be appended |
651 * @param result where the text is to be appended |
640 * @param fieldPosition On input: an alignment field, if desired. |
652 * @param fieldPosition keeps track on the position of the field within |
641 * On output: the offsets of the alignment field. |
653 * the returned string. For example, for formatting |
|
654 * a number {@code 123456789} in {@code Locale.US} |
|
655 * locale, if the given {@code fieldPosition} is |
|
656 * {@link NumberFormat#INTEGER_FIELD}, the begin index |
|
657 * and end index of {@code fieldPosition} will be set |
|
658 * to 0 and 11, respectively for the output string |
|
659 * {@code 123,456,789}. |
642 * @exception NullPointerException if {@code result} or |
660 * @exception NullPointerException if {@code result} or |
643 * {@code fieldPosition} is {@code null} |
661 * {@code fieldPosition} is {@code null} |
644 * @exception ArithmeticException if rounding is needed with rounding |
662 * @exception ArithmeticException if rounding is needed with rounding |
645 * mode being set to RoundingMode.UNNECESSARY |
663 * mode being set to RoundingMode.UNNECESSARY |
646 * @return The formatted number string |
664 * @return The formatted number string |
725 |
743 |
726 /** |
744 /** |
727 * Formats a BigDecimal to produce a string. |
745 * Formats a BigDecimal to produce a string. |
728 * @param number The BigDecimal to format |
746 * @param number The BigDecimal to format |
729 * @param result where the text is to be appended |
747 * @param result where the text is to be appended |
730 * @param fieldPosition On input: an alignment field, if desired. |
748 * @param fieldPosition keeps track on the position of the field within |
731 * On output: the offsets of the alignment field. |
749 * the returned string. For example, for formatting |
|
750 * a number {@code 1234567.89} in {@code Locale.US} |
|
751 * locale, if the given {@code fieldPosition} is |
|
752 * {@link NumberFormat#INTEGER_FIELD}, the begin index |
|
753 * and end index of {@code fieldPosition} will be set |
|
754 * to 0 and 9, respectively for the output string |
|
755 * {@code 1,234,567.89}. |
732 * @return The formatted number string |
756 * @return The formatted number string |
733 * @exception ArithmeticException if rounding is needed with rounding |
757 * @exception ArithmeticException if rounding is needed with rounding |
734 * mode being set to RoundingMode.UNNECESSARY |
758 * mode being set to RoundingMode.UNNECESSARY |
735 * @see java.text.FieldPosition |
759 * @see java.text.FieldPosition |
736 */ |
760 */ |
778 |
802 |
779 /** |
803 /** |
780 * Format a BigInteger to produce a string. |
804 * Format a BigInteger to produce a string. |
781 * @param number The BigInteger to format |
805 * @param number The BigInteger to format |
782 * @param result where the text is to be appended |
806 * @param result where the text is to be appended |
783 * @param fieldPosition On input: an alignment field, if desired. |
807 * @param fieldPosition keeps track on the position of the field within |
784 * On output: the offsets of the alignment field. |
808 * the returned string. For example, for formatting |
|
809 * a number {@code 123456789} in {@code Locale.US} |
|
810 * locale, if the given {@code fieldPosition} is |
|
811 * {@link NumberFormat#INTEGER_FIELD}, the begin index |
|
812 * and end index of {@code fieldPosition} will be set |
|
813 * to 0 and 11, respectively for the output string |
|
814 * {@code 123,456,789}. |
785 * @return The formatted number string |
815 * @return The formatted number string |
786 * @exception ArithmeticException if rounding is needed with rounding |
816 * @exception ArithmeticException if rounding is needed with rounding |
787 * mode being set to RoundingMode.UNNECESSARY |
817 * mode being set to RoundingMode.UNNECESSARY |
788 * @see java.text.FieldPosition |
818 * @see java.text.FieldPosition |
789 */ |
819 */ |