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

java.sql.TimeStamp results in wrong time for some timezones when dates are in BC

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.2.2_018
    • 1.3.1_04
    • core-libs
    • None
    • 018
    • sparc
    • solaris_8

        Oracle engineering have found a problem with the Sun JVM or API's that cause the time to be incorrect for some timezones when the date is in BC. This impacts their application server product.

        In our testing all versions tested 1.3.1_09 and before exhibit this problem. All versions tested 1.4.0_FCS and later do not exhibit this problem. While Oracle have identified this problem against java.sql.TimeStamp it's superclass java.util.Date also exhibits this problem.

        This simple test case demonstrates the problem:

        import java.sql.SQLException;

        public class test2 {
          static public void main(String args[]) throws SQLException {
            java.sql.Timestamp ts = new java.sql.Timestamp(-6611, 0, 1, 0, 0, 0, 0);
            System.out.println("ts.toString() "+ ts.toString());
          }
        }

        Then compile and run with timezone set specifically in the environment:
        $ javac test2.java
        $ export TZ=Australia/Queensland
        $ java test2

        The results were as follows:

        Results from a US based machine with default TZ US/Pacifiic are:

          JDK version TZ Result
          ------------------------------------------------------------------
          1.2.2 US/Pacific 4712-01-01 00:00:00.0
          1.2.2 Australia/Queensland 4712-12-31 23:00:00.0 (*)
          1.2.2 Australia/Melbourne 4712-01-01 00:00:00.0
          1.3 US/Pacific 4712-01-01 00:00:00.0
          1.3 Australia/Queensland 4712-12-31 23:00:00.0 (*)
          1.3 Australia/Melbourne 4712-01-01 00:00:00.0
          1.3.1 US/Pacific 4712-01-01 00:00:00.0
          1.3.1 Australia/Queensland 4712-01-01 00:00:00.0
          1.3.1 Australia/Melbourne 4712-12-31 23:00:00.0 (*)
          1.4 US/Pacific 4712-01-01 00:00:00.0
          1.4 Australia/Queensland 4712-01-01 00:00:00.0
          1.4 Australia/Melbourne 4712-01-01 00:00:00.0
        (*) => incorrect

              minqi Yumin Qi
              duke J. Duke
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: