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

java.sql.Timestamp.toString() method works wrong with nanos

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.1
    • CPU:
      sparc
    • OS:
      solaris_2.5
    • Verification:
      Not verified

      Description

      This method can round nanos or output them in scientific notation.

      === Here is the minimized test demonstrating the bug ===

      import java.sql.Timestamp;
      class java_sql_Timestamp1 {
        public static void main (String args[]) {
          Timestamp t1=new java.sql.Timestamp(96,8,13,5,8,13,2);
          System.out.println(t1);
          //will print "1996-09-13 05:08:13.0E-9" instead of "1996-09-13 05:08:13.000000002"
          Timestamp t2=new java.sql.Timestamp(96,8,13,5,8,13,499999998);
          System.out.println(t2);
          //will print "1996-09-13 05:08:13.5" instead of "1996-09-13 05:08:13.499999998 "
        }
      }

      === Here is the test output ===
      1996-09-13 05:08:13.0E-9
      1996-09-13 05:08:13.5

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: