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

fp.bugs 3134 Date parse() throws IllegalArgumentException on -

    XMLWordPrintable

    Details

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

      Description

      When you make a call of the variety

      long l = d.parse("Sat, 12 Aug 1995 12:30:00 GMT-0430");

      where d is an instance of the Date class, you get

       java.lang.IllegalArgumentException
      at java.util.Date.parse(Date.java)
      at test.main(test.java:7)

      Here is code that is almost a test:
      import java.lang.*;
      import java.io.*;
      import java.util.Date;
      class test {
      public static void main (String arg[]) throws IOException {
       Date d = new Date();
      long l = d.parse("Sat, 12 Aug 1995 12:30:00 GMT-0430");

      }

      ____Customer Report Follows____
      >From: ED <###@###.###>
      Mime-Version: 1.0
      To: java@java
      Subject: Bug in Date Class
      X-Url: http://java.sun.com/intouch.html
      Content-Transfer-Encoding: 7bit

      Hi, Guys,

      I just figured out a bug in the Date Class,

      In funciton Parse (line of 248)source code Date.java, the char "-" has
      been ignored. But it was checked for GMT time zone and "-" may be used
      for east timezone and program will cause IllegalArgumentException.

      Ed Zhou (###@###.###)

      [meiphen 8/28/96]
      Another customer reports the same problem:

      I believe there is a bug in the parse(String) routine in
      java.util.Date, because it does not handle negative timezone offsets.
      For example:

      Date foo = new Date("Fri, 24 May 1996 10:55:11 -0600");

      This throws an IllegalArgumentException, because of the "-0600". It
      appears to me that in java.util.Date on line 248:

      if (c <= ' ' || c == ',' || c == '-')
      continue;

      The minus sign should not be included in this list. When I change the
      line to:

      if (c <= ' ' || c == ',')
      continue;

      ...the date parses correctly. I do not know what other side-effects
      this may cause however.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              duke J. Duke (Inactive)
              Reporter:
              bhagen Benjamin Hagen (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: