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

java.sql.Timestamp.toString() method works wrong when nanos = 0

XMLWordPrintable

    • 1.1
    • sparc
    • solaris_2.5
    • Not verified

      This methods returns "1996-12-13 14:15:25." instead of
      "1996-12-13 14:15:25.0" or "1996-12-13 14:15:25" or "1996-12-13 14:15:25.000000000"
      (it is not clear from specification which result is correct)

      ==== Here is the test demonstrating the bug ====
      import java.sql.Timestamp;
      class java_sql_Timestamp6 {
        public static void main (String args[]) {
            Timestamp ts=Timestamp.valueOf("1996-12-13 14:15:25.0");
            System.out.println("ts = " + ts);
        }
      }
      === Here is the test output ===
      ts = 1996-12-13 14:15:25.

            mhapnersunw Mark Hapner (Inactive)
            mgorshen Mikhail Gorshenev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: