JDK-8326158 : Javadoc for java.time.DayOfWeek#minus(long)
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.time
  • Affected Version: 8,11,17,21
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2024-02-18
  • Updated: 2024-02-27
  • Resolved: 2024-02-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 23
23 b11Fixed
Related Reports
Duplicate :  
Description
A DESCRIPTION OF THE PROBLEM :
It's likely an erratum in the document of `java.time.DayOfWeek#minus(long)` that in

 "The calculation rolls around the start of the year from Monday to Sunday."

This should be 
"The calculation rolls around the end of the week from Monday to Sunday."

However in java.time.DayOfWeek#plus() it is :

"The calculation rolls around the end of the week from Sunday to Monday."


Both minus() and plus() uses "week" as per implementation.

It's found in both https://docs.oracle.com/javase/8/docs/api/ and https://download.java.net/java/early_access/jdk23/docs/api/java.base/java/time/DayOfWeek.html#minus(long)



Comments
Changeset: 64f7972a Author: Naoto Sato <naoto@openjdk.org> Date: 2024-02-21 16:53:57 +0000 URL: https://git.openjdk.org/jdk/commit/64f7972a3d0c82ad7047f73f0b57c3d88f62935f
21-02-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/17933 Date: 2024-02-20 18:34:59 +0000
20-02-2024

Obviously a typo. Possibly copy/pasted from `java.time.Month#minus(long)` and left unmodified.
20-02-2024

The documentation for DayOfWeek.#minus() says the calculation rolls around the 'start of the year from Monday to Sunday' instead of 'start of the week from Monday to Sunday'. This issue can be observed from JDK 8 onwards. JDK 21 - https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/time/DayOfWeek.html#minus(long) JDK 22ea - https://download.java.net/java/early_access/jdk22/docs/api/java.base/java/time/DayOfWeek.html#minus(long) JDK 23ea - https://download.java.net/java/early_access/jdk23/docs/api/java.base/java/time/DayOfWeek.html#minus(long)
19-02-2024