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

Remove minimum 4 digit requirement from Year.parse()

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P4
    • Resolution: Approved
    • Fix Version/s: 16
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      behavioral
    • Compatibility Risk:
      low
    • Compatibility Risk Description:
      With this change, the exception will not be thrown with years of 3 digits or less.
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      Summary

      Remove the restriction in java.time.Year.parse() method which requires the argument to have at least 4 digits.

      Problem

      java.time.Year.parse(CharSequence) method requires the argument to have at least four digits. For example,

      Year.parse("200")

      is currently throwing a DateTimeParseException. To parse year 200 correctly, the argument needs zero paddings, ie., "0200".

      Solution

      Make the parsing more lenient. It should accept years without leading zeroes.

      Specification

      Remove the following sentence in the method description of java.time.Year.parse().

      Years outside the range 0000 to 9999 must be prefixed by the plus or minus symbol.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              naoto Naoto Sato
              Reporter:
              scolebourne Stephen Colebourne
              Reviewed By:
              Roger Riggs
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: