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

SimpleDateFormat doesn't support RFC822 format

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 6u16
    • core-libs
    • x86
    • windows_7

      FULL PRODUCT VERSION :
      1.5, and probably others.
      1.6.0_16-b01

      A DESCRIPTION OF THE PROBLEM :
      SimpleDateFormat RFC822 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
      RFC822.parse("2009-08-07T15:00:00.000-0000"); // Succeeds -- no colon in tz offset
      RFC822.parse("2009-08-07T15:00:00.000-05:00"); // Fails -- colon in tz offset
      RFC822.parse("2009-08-07T15:00:00.000Z"); // Fails -- "Z" used for Zulu

      My reading of http://tools.ietf.org/html/rfc3339#section-5.8 is that the time zone offset should include a colon, and that "Z" is a valid suffix (representing Zulu time). The feed I receive (Google Calendar) does return timestamps with colons or Z. I would like to parse those times, but SimpleDateFormat won't cooperate. SimpleDateFormat documentation states that the pattern character "Z" is a "RFC 822 time zone". So either the documentation is wrong, the implementation is wrong, or I'm just mixed up.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Use my code snippet, above.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expect valid RFC822 time stamps to be parsed.
      ACTUAL -
      Valid RFC822 time stamps failed to parse.

      REPRODUCIBILITY :
      This bug can be reproduced always.

            okutsu Masayoshi Okutsu
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: