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

jdk regression:Timestamp.toString() returns wrong string

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 1.4.0
    • core-libs
    • sparc
    • solaris_2.6



      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

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

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: