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

java.util.GregorianCalendar.equals() ignores cutover date.

    XMLWordPrintable

    Details

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

      Description



      Name: dfC67450 Date: 05/26/98



      java.util.GregorianCalendar.equals returns true even if GregorianChange settings
      are different.

      Here is the test demonstrating the bug:

      -----------------Test.java------------------------
      import java.util.*;

      public class Test {
          public static void main (String args[]){
              GregorianCalendar c1 = new GregorianCalendar(1998, 1, 1);
              GregorianCalendar c2 = new GregorianCalendar(1998, 1, 1);
              c1.setGregorianChange(new Date(0));
              c2.setGregorianChange(new Date(1000*60*60*24*10));
              if (c1.equals(c2)) {
                System.out.println("Test failed");
                System.out.println(" two calendars are equal");
                System.out.println(" c1.getGregorianChange: " + c1.getGregorianChange());
                System.out.println(" c2.getGregorianChange: " + c2.getGregorianChange());
              } else {
                System.out.println("Test passed");
              }
          }
        
      }
      ---------Output from the test---------------------
      Test failed
        two calendars are equal
        c1.getGregorianChange: Thu Jan 01 00:00:00 GMT 1970
        c2.getGregorianChange: Sun Jan 11 00:00:00 GMT 1970
      -------------------------------------------------

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

        Attachments

          Activity

            People

            Assignee:
            aliusunw Alan Liu (Inactive)
            Reporter:
            dfazunensunw Dmitri Fazunenko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: