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

Date.toString() produces a time zone that can't be parsed by Date.parse()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P5 P5
    • None
    • 1.3.0
    • core-libs



      Name: skR10017 Date: 05/22/2000



      The following test invokes Date() constructor and retrieves it's string representation
      with Date.toString() method. Then test tries to create new Date class from
      this string representation but under

      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0beta-b05)
      Java HotSpot(TM) Client VM (build 1.3.0beta-b03, mixed mode)
      ( Linux platform )

      IllegalArgumentException is thrown.

      The test DateRegression in testbase_js (jit/symcjit/4139731/Date/DateRegression)
      and the test in regression testsuite (java/util/Date/DateRegression) fail due to the same
      reason.
      --------------------------------- test.java --------------------
      import java.util.*;
      public class test {
          public static void main(String[] args) {
              Date now = new Date();
              Date now2 = new Date(now.toString());
           }
      }
      -------------------------------------------------------------
      Under Solaris test passes.

      ======================================================================
      Java 2 Platform SE v1.3 Specification reads:

      public String toString()

            Converts this Date object to a String of the form:

                   dow mon dd hh:mm:ss zzz yyyy

            where:
      ----- cut ------
                  zzz is the time zone (and may reflect daylight savings time).
      Standard time zone
                  abbreviations include those recognized by the method parse. If time
      zone
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                  informationi is not available, then zzz is empty - that is, it
      consists of no
                  characters at all.
                  yyyy is the year, as four decimal digits.

      This means that if this string is given to Date(String s) constructor it should
      understand it.

      Example of string that is returned by Date.toString() method under Linux:
      Tue May 23 12:21:56 GMT+07:00 2000

      If you remove colon after GMT+07 and give the following string:
      Tue May 23 12:21:56 GMT+0700 2000
      to Date(String s) constructor everything works fine.

      Specification reads about Date(String s) constructor that there should be no
      colon
      in time zone field.

      Sergei Kotlyachkov 05/25/2000



      Name: egR10015 Date: 11/04/2003


      This bug affects the following test:

      regression/jit/4139731/Date/DateRegression

      from testbase_vm.
      ======================================================================

            okutsu Masayoshi Okutsu
            kotlsunw Kotl Kotl (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: