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

Incorrect statement about an absolute value of months unit after period's normalization

    Details

    • Subcomponent:
    • Resolved In Build:
      b151
    • Verification:
      Not verified

      Description

      A DESCRIPTION OF THE PROBLEM :
      There is "11" but I think it should be "12" in the following sentence:
      "The months unit is adjusted to have an absolute value less than 11, with the years unit being adjusted to compensate."

      According to:
      https://docs.oracle.com/javase/8/docs/api/java/time/Period.html#getMonths--
      the method getMonths() "returns the months unit", so the following code returns the period's months unit after normalization:
      java.time.Period.ofMonths(11).normalized().getMonths()
      This code correctly returns 11, but 11 is not "an absolute value less than 11".

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Returns a copy of this period with the years and months normalized.

      This normalizes the years and months units, leaving the days unit unchanged. The months unit is adjusted to have an absolute value less than 12, with the years unit being adjusted to compensate. For example, a period of "1 Year and 15 months" will be normalized to "2 years and 3 months".

      The sign of the years and months units will be the same after normalization. For example, a period of "1 year and -25 months" will be normalized to "-1 year and -1 month".

      This instance is immutable and unaffected by this method call.
      ACTUAL -
      Returns a copy of this period with the years and months normalized.

      This normalizes the years and months units, leaving the days unit unchanged. The months unit is adjusted to have an absolute value less than 11, with the years unit being adjusted to compensate. For example, a period of "1 Year and 15 months" will be normalized to "2 years and 3 months".

      The sign of the years and months units will be the same after normalization. For example, a period of "1 year and -25 months" will be normalized to "-1 year and -1 month".

      This instance is immutable and unaffected by this method call.

      URL OF FAULTY DOCUMENTATION :
      https://docs.oracle.com/javase/8/docs/api/java/time/Period.html#normalized--

        Issue Links

          Activity

          Hide
          psonal Pallavi Sonal added a comment -
          URLs:JDK 9 http://download.java.net/java/jdk9/docs/api/java/time/Period.html#normalized--
                    JDK 8 https://docs.oracle.com/javase/8/docs/api/java/time/Period.html#normalized--

          The submitter's observation looks correct, either it should be "absolute value less than 12" or "absolute value less than or equal to 11" , because once the month unit reaches 12 then only it is adjusted to a year unit.
          Show
          psonal Pallavi Sonal added a comment - URLs:JDK 9 http://download.java.net/java/jdk9/docs/api/java/time/Period.html#normalized--           JDK 8 https://docs.oracle.com/javase/8/docs/api/java/time/Period.html#normalized-- The submitter's observation looks correct, either it should be "absolute value less than 12" or "absolute value less than or equal to 11" , because once the month unit reaches 12 then only it is adjusted to a year unit.
          Hide
          hgupdate HG Updates added a comment -
          URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/2ec3c5b622ca
          User: rriggs
          Date: 2016-12-23 18:51:28 +0000
          Show
          hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/2ec3c5b622ca User: rriggs Date: 2016-12-23 18:51:28 +0000
          Hide
          hgupdate HG Updates added a comment -
          URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/2ec3c5b622ca
          User: lana
          Date: 2017-01-04 20:58:34 +0000
          Show
          hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/2ec3c5b622ca User: lana Date: 2017-01-04 20:58:34 +0000

            People

            • Assignee:
              rriggs Roger Riggs
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: