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

java.time.format.DateTimeFormatter cannot parse an offset with single digit hour

    Details

    • Subcomponent:
    • Introduced In Version:
      8
    • Resolved In Build:
      b130
    • CPU:
      generic
    • OS:
      generic

      Description

      There's no way to parse a single digit hour in the offset. Example:

        2011-01-20 02:55:07.532941 -8:00

      The spec needs to be modified to cover this case and the code enhanced to support it.

      The only workaround is to parse the date/time separately, use a hand coded parser for the offset and combine the LocalDateTime with the hand parsed offset. Not an easy work around.

      I have run across some occurrences of this though I can't say how common it is.

        Activity

        Hide
        scolebourne Stephen Colebourne added a comment -
        If the pattern contains "H" then it has to parse either 1 or 2 digits regardless of mode.
        Show
        scolebourne Stephen Colebourne added a comment - If the pattern contains "H" then it has to parse either 1 or 2 digits regardless of mode.
        Show
        ntv Nadeesh Tv (Inactive) added a comment - http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-May/041487.html
        Hide
        ntv Nadeesh Tv (Inactive) added a comment -
        FC Extension Request:

        Status: Review ongoing in core-libs-dev http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-May/041487.html

        Justification:
         • At present, java.time.format.DateTimeFormatter cannot parse an offset with single digit
           hour. Since most of the countries time zone have single digit hour (America/Newyork-5,
           Germany/Berlin +2 etc..) in offset, we should enhance the offset by
           introducing following patterns:
              +H, +Hmm, +H:mm, +HMM, +H:MM, +HMMss, +H:MM:ss,
              +HMMSS, +H:MM:SS, +Hmmss, +H:mm:ss
           this enhancement will be useful to most developers.

        Remaining work to be done:

        Test cases for lenient scenario

        Compatibility Risk:
          • Minimal (no existing tests will fail)

        Change will be integrated (locally) by: 2016-06-24
        Show
        ntv Nadeesh Tv (Inactive) added a comment - FC Extension Request: Status: Review ongoing in core-libs-dev http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-May/041487.html Justification:  • At present, java.time.format.DateTimeFormatter cannot parse an offset with single digit    hour. Since most of the countries time zone have single digit hour (America/Newyork-5,    Germany/Berlin +2 etc..) in offset, we should enhance the offset by    introducing following patterns:       +H, +Hmm, +H:mm, +HMM, +H:MM, +HMMss, +H:MM:ss,       +HMMSS, +H:MM:SS, +Hmmss, +H:mm:ss    this enhancement will be useful to most developers. Remaining work to be done: Test cases for lenient scenario Compatibility Risk:   • Minimal (no existing tests will fail) Change will be integrated (locally) by: 2016-06-24
        Hide
        hgupdate HG Updates added a comment -
        URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/0881ab3faeb4
        User: ntv
        Date: 2016-07-28 10:29:03 +0000
        Show
        hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/0881ab3faeb4 User: ntv Date: 2016-07-28 10:29:03 +0000
        Hide
        hgupdate HG Updates added a comment -
        URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/0881ab3faeb4
        User: amurillo
        Date: 2016-08-03 16:28:12 +0000
        Show
        hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/0881ab3faeb4 User: amurillo Date: 2016-08-03 16:28:12 +0000

          People

          • Assignee:
            ntv Nadeesh Tv (Inactive)
            Reporter:
            dsurber Douglas Surber
          • Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: