Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4088503

java.text.DecimalFormat.format() fails when groupingSize is set to 0

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.1.6
    • CPU:
      sparc
    • OS:
      solaris_2.5
    • Verification:
      Verified

      Backports

        Description



        Name: dfC67450 Date: 10/24/97



        java.text.DecimalFormat.format(long, StringBuffer, FieldPosition) throws
        unexpected "java.lang.ArithmeticException: / by zero" if groupingSize field
        of DecimalFormat object is set to 0.

        Here is the test demonstrating the bug:

        -----------------Test.java------------------------
        import java.text.*;

        public class Test {
            public static void main (String args[]){
                DecimalFormat df = new DecimalFormat();
                df.setGroupingSize(0);
                StringBuffer sBuf = new StringBuffer("");
                FieldPosition fp = new FieldPosition(0);
                System.out.println(df.format(123, sBuf, fp));
            }
        }
        ---------Output from the test---------------------
        java.lang.ArithmeticException: / by zero
                at java.text.DecimalFormat.appendNativeDigits(DecimalFormat.java)
                at java.text.DecimalFormat.format(DecimalFormat.java)
                at TestForm.main(TestForm.java:9)
        --------------------------------------------------

        ======================================================================

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                joconnersunw John Oconner (Inactive)
                Reporter:
                dfazunensunw Dmitri Fazunenko (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: