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

java.util.Date fails if current TimeZone is changed (regression)

XMLWordPrintable

    • 1.1.6
    • sparc
    • solaris_2.5
    • Verified



        Name: mgC56079 Date: 02/02/98



        The java.util.Date class works wrong if the current TimeZone is changed
        after the class has been loaded.
        This bug is introduced in jdk1.1.6

        ----- Here is the test -----
        import java.util.TimeZone;
        import java.util.Date;
        public class TZ {

          public static void main(String args[]) {

            // load the java.util.Date class in the GMT timezone
            TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
            new Date(); // load the class (to run static initializers)

            // use the class in different timezone
            TimeZone.setDefault(TimeZone.getTimeZone("PST"));
            System.out.println("Expected: Sat Feb 01 00:00:00 PST 1997");
            System.out.println("Result: "+new Date(97,1,1));
          }

        }
        ----- Here is the correct output (jdk1.1.5) -----
        Expected: Sat Feb 01 00:00:00 PST 1997
        Result: Sat Feb 01 00:00:00 PST 1997

        ----- Here is the WRONG output (jdk1.1.6) -----
        Expected: Sat Feb 01 00:00:00 PST 1997
        Result: Fri Jan 31 16:00:00 PST 1997

        ----------

        The bug causes a JCK test failure:
        api/java_sql/Timestamp/manual.html#Ctor

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

              ssenthilsunw Shanmugam Senthil (Inactive)
              mgorshen Mikhail Gorshenev (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: