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

java.util.SimpleTimeZone.hasSameRules(TimeZone) works wrong

    • 1.2fcs
    • sparc
    • solaris_2.5
    • Verified



      Name: avC70361 Date: 07/03/98



        java.util.SimpleTimeZone.hasSameRules(TimeZone) works wrong when compares
      two SimpleTimeZone instances both without rules. It returns false when two
      instances have been constructed with different values of rule fields, but
      specifying that time zone has no rules. Zones constructed this way behave the
      same whereas hasSameRules returns false.

      Here is a test demonstrating the bug.
      ---------------HasSameRulesTest.java-----------
      import java.util.SimpleTimeZone;

      public class HasSameRulesTest {

        public static void main(String args[]) {
          SimpleTimeZone tz1 = new SimpleTimeZone(0, "stz", 0, 0, 0, 0, 2, 0, 0, 0);
          SimpleTimeZone tz2 = new SimpleTimeZone(0, "stz", 1, 0, 0, 0, 3, 0, 0, 0);

          if (!tz1.hasSameRules(tz2)) {
            System.out.println(
              "Failed: hasSameRules() returns false for zones without rules\nzone 1 = " + tz1 + "\nzone 2 = " + tz2
            );
          }
        }
      }

      ---------The test output--------
      > java HasSameRulesTest
      Failed: hasSameRules() returns false for zones without rules
      zone 1 = java.util.SimpleTimeZone[id=stz,offset=0,dstSavings=3600000,useDaylight=false,startYear=0,startMode=1,startMonth=0,startDay=0,startDayOfWeek=0,startTime=0,endMode=1,endMonth=2,endDay=0,endDayOfWeek=0,endTime=0]
      zone 2 = java.util.SimpleTimeZone[id=stz,offset=0,dstSavings=3600000,useDaylight=false,startYear=0,startMode=1,startMonth=1,startDay=0,startDayOfWeek=0,startTime=0,endMode=1,endMonth=3,endDay=0,endDayOfWeek=0,endTime=0]

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

            aliusunw Alan Liu (Inactive)
            ovlasov Oleksandr Vlasov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: