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

java.sql.Timestamp reports wrong time in some cases

XMLWordPrintable

    • x86
    • linux

      Name: rmT116609 Date: 03/02/2004


      FULL PRODUCT VERSION :
      java version "1.4.2_02"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_02-b03)
      Java HotSpot(TM) Client VM (build 1.4.2_02-b03, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Linux 2.4.20-20.9 #1 Mon Aug 18 11:45:58 EDT 2003 i686 i686 i386 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      java.sql.Timestamp report a wrong time in some cases


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      run the test code I provide

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      2001-04-01 00:10:44 -> 2001-04-01 00:10:44.0
      2001-04-01 01:21:25 -> 2001-04-01 01:21:25.0
      err: 2001-04-01 02:32:11 -> 2001-04-01 02:32:11.0
      err: 2001-04-01 02:44:15 -> 2001-04-01 02:44:15.0
      err: 2001-04-01 02:49:35 -> 2001-04-01 02:49:35.0
      2001-04-01 03:29:26 -> 2001-04-01 03:29:26.0

      ACTUAL -
      2001-04-01 00:10:44 -> 2001-04-01 00:10:44.0
      2001-04-01 01:21:25 -> 2001-04-01 01:21:25.0
      err: 2001-04-01 02:32:11 -> 2001-04-01 03:32:11.0
      err: 2001-04-01 02:44:15 -> 2001-04-01 03:44:15.0
      err: 2001-04-01 02:49:35 -> 2001-04-01 03:49:35.0
      2001-04-01 03:29:26 -> 2001-04-01 03:29:26.0



      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32c)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)

      C:\tmpjava>java Bug
      2001-04-01 00:10:44 -> 2001-04-01 00:10:44.0
      2001-04-01 01:21:25 -> 2001-04-01 01:21:25.0
      err: 2001-04-01 02:32:11 -> 2001-04-01 03:32:11.0
      err: 2001-04-01 02:44:15 -> 2001-04-01 03:44:15.0
      err: 2001-04-01 02:49:35 -> 2001-04-01 03:49:35.0
      2001-04-01 03:29:26 -> 2001-04-01 03:29:26.0


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.io.*;
      import java.util.*;
      import java.sql.Timestamp;

      class Bug {
          public static void main (String args[]) {
              String str_ts;
              Timestamp ts;
              
              str_ts = "2001-04-01 00:10:44";
              ts = Timestamp.valueOf(str_ts);
              System.out.println(str_ts + " -> " + ts.toString());
              
              str_ts = "2001-04-01 01:21:25";
              ts = Timestamp.valueOf(str_ts);
              System.out.println(str_ts + " -> " + ts.toString());
              
              str_ts = "2001-04-01 02:32:11";
              ts = Timestamp.valueOf(str_ts);
              System.out.println("err:\t" + str_ts + " -> " + ts.toString());

              str_ts = "2001-04-01 02:44:15";
              ts = Timestamp.valueOf(str_ts);
              System.out.println("err:\t" + str_ts + " -> " + ts.toString());
              
              str_ts = "2001-04-01 02:49:35";
              ts = Timestamp.valueOf(str_ts);
              System.out.println("err:\t" + str_ts + " -> " + ts.toString());
              
              str_ts = "2001-04-01 03:29:26";
              ts = Timestamp.valueOf(str_ts);
              System.out.println(str_ts + " -> " + ts.toString());
          }
      }

      ---------- END SOURCE ----------
      (Incident Review ID: 225826)
      ======================================================================

            lancea Lance Andersen
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: