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

jdk regression:Timestamp.toString() returns wrong string

    XMLWordPrintable

Details

    • beta2
    • sparc
    • solaris_2.6
    • Verified

    Description



      Name: auR10023 Date: 07/06/2001


      Timestamp.toString() method returns wrong string representation for
      Timestamp(Long.MAX_VALUE) object. The javadoc says:
      ...
      public Timestamp(long time)

           Constructs a Timestamp object using a milliseconds time value. The integral
           seconds are stored in the underlying date value; the fractional seconds are
           stored in the nanos field of the Timestamp object.

           Parameters:
                time - milliseconds since January 1, 1970, 00:00:00 GMT. A negative
                number is the number of milliseconds before January 1, 1970, 00:00:00
                GMT.
      ...

      Following example shows that if Long.MAX_VALUE is used as a parameter for
      this constructor then this constructor creates object with less then 1970
      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 (Long.MAX_VALUE);
              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

      994-08-17 07:12:55.807
      Sun Aug 17 07:12:55 GMT+03:00 292278994

      #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)

      292278994-08-17 07:12:55.807
      Sun Aug 17 07:12:55 GMT+03:00 292278994

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

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: