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

JFR: PrettyWriter uses incorrect year specifier

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 18
    • Fix Version/s: 18
    • Component/s: hotspot
    • Subcomponent:
      jfr
    • Resolved In Build:
      b27

      Description

      Found by SonarCloud, actually.

      For this commit:
      https://github.com/openjdk/jdk/commit/ee3576a48b700df3d8ad4bd447346d4102b20818

      It says:

      "Week Year ("YYYY") should not be used for date formatting

      Few developers are aware of the difference between Y for "Week year" and y for Year when formatting and parsing a date with SimpleDateFormat or DateTimeFormatter. That's likely because for most dates, Week year and Year are the same, so testing at any time other than the first or last week of the year will yield the same value for both y and Y. But in the last week of December and the first week of January, you may get unexpected results."

      See also ErrorProne rule: https://errorprone.info/bugpattern/MisusedWeekYear

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              shade Aleksey Shipilev
              Reporter:
              shade Aleksey Shipilev
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: