Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-1206

Sling Post servlet incorrectly parses ISO8601 date formats with timezone offset (as used by JCR)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • Servlets Post 2.0.2, Servlets Post 2.0.4
    • Servlets Post 2.1.0
    • Servlets
    • None

    Description

      An ISO8601 date format, as it is returned by javax.jcr.Property.getString() for date properties, looks like this:

      2009-11-18T11:30:00+10:30

      When roundtripping this string by posting it to the sling post servlet (using @TypeHint=Date), it will be parsed by this pattern "yyyy-MM-dd'T'HH:mm:ss", configured as third in the SlingPostServlet's servlet.post.dateFormats config. But then timezone information is lost and the default timezone of the server will be used, which produces a wrong date in the end.

      The problem is that Java's SimpleDateFormat used in the SlingPostServlet (DateParser class), does not support the ISO8601 way of specifying timezone offsets at all. It either supports "GMT+10:30", where "GMT" must be present, or the RFC-822 style "+1030", without the colon.

      To support proper round-tripping, with date strings rendered directly from a JCR property, I suggest to
      a) introduce a special pattern string such as "iso8601" that uses the ISO8601 utility class from jackrabbit-jcr-commons
      b) set this format as second one in the servlet.post.dateFormats list (before the problematic ones, but after the ECMA date format, which is needed for roundtripping with Sling JSON exports)

      Attachments

        Activity

          People

            fmeschbe Felix Meschberger
            alexander.klimetschek Alexander Klimetschek
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: