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

jdk regression:Timestamp.toString() returns wrong string

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Duplicate
    • Affects Version/s: 1.4.0
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.6

      Description



      Name: auR10023 Date: 07/06/2001


      Timestamp.toString() method returns wrong string representation for
      Timestamp(9998, 5, 20, 2, 12, 59, 547500000) object. The javadoc says:

      ...
      public Timestamp(int year,
                       int month,
                       int date,
                       int hour,
                       int minute,
                       int second,
                       int nano)

           Deprecated. instead use the constructor Timestamp(long millis)

           Constructs a Timestamp object initialized with the given values.

           The result is undefined if a given argument is out of bounds.

           Parameters:
                year - the year minus 1900; must be 0 to 9999
                month - 0 to 11
                date - 1 to 31
                hour - 0 to 23
                minute - 0 to 59
                second - 0 to 59
                nano - 0 to 999,999,999
           Throws:
                IllegalArgumentException - if the nano argument is out of bounds
      ...

      Following example shows that if the valid parameters is passed to this
      constructor then this constructor creates object with wrong year in the
      string representation.

      Here is the example:

      ----t.java---

      import java.util.*;
      import java.sql.Timestamp;

      class t {
          public static void main (String [] args) {
              Timestamp t = new Timestamp(9998, 5, 20, 2, 12, 59, 547500000);
              System.out.println(t);
              System.out.println(new Date(t.getTime()));
          }
      }

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

      #java t

      898-06-20 02:12:59.5475
      Mon Jun 20 02:12:59 GMT+03:00 11898

      #java -version
      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, interpreted mode)

      #java t

      11898-06-20 02:12:59.5475
      Mon Jun 20 02:12:59 GMT+03:00 11898

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jbrucesunw Jonathan Bruce (Inactive)
              Reporter:
              avusunw Avu Avu (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: