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

java.text.NumberFormat.equals(Object) method doesn't work correctly.

    XMLWordPrintable

Details

    • 1.1.6
    • sparc
    • solaris_2.5
    • Verified

    Backports

      Description



        Name: mgC56079 Date: 08/26/97



        The java.text.NumberFormat.equals() method does not work correctly.
        This method should return false if two objects are different.
        But it ignores setting of GroupingUsed flag.

        Here is the test demonstrating the bug:

        -----------------NumberFormatEqualsTest.java------------------------
        import java.text.*;

        public class NumberFormatEqualsTest {
          
          public static void main(String args[]) {
            
            NumberFormatTest nf1 = new NumberFormatTest();
            NumberFormatTest nf2 = new NumberFormatTest();
            
            nf1.setGroupingUsed(false);
            nf2.setGroupingUsed(true);
          
            if (nf1.equals(nf2)) System.out.println("Test failed");
            return;
          }
        }


          // implementation of abstract method of the NumberFormat class

        class NumberFormatTest extends NumberFormat {
           public StringBuffer format(double number,
                                StringBuffer toAppendTo,
                                FieldPosition pos) {
              return new StringBuffer("");
            }
            public StringBuffer format(long number,
                                StringBuffer toAppendTo,
                                FieldPosition pos) {
              return new StringBuffer("");
            }
            public Number parse(String text, ParsePosition parsePosition) {
              return new Integer(0);
            }
        }

           
        ---------Output from the test---------------------
        Test failed
        --------------------------------------------------
           
        ======================================================================

        Attachments

          Issue Links

            Activity

              People

                joconnersunw John Oconner (Inactive)
                mgorshen Mikhail Gorshenev (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: