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

HijrahDate aligned day of week incorrect

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8, 9
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b142

      Description

      The HijrahDate class incorrectly calculates the aligned-day-of-week field. It based the calculation on the day-of-week, when it should be based on the day-of-month.

      HijrahDate line 372:
       case ALIGNED_DAY_OF_WEEK_IN_MONTH: return ((getDayOfWeek() - 1) % 7) + 1;
      should be:
       case ALIGNED_DAY_OF_WEEK_IN_MONTH: return ((dayOfMonth - 1) % 7) + 1;

      Proposed test case:

          public void test_alignedDayOfWeekInMonth() {
              for (int dom = 1; dom <= 29; dom++) {
                  HijrahDate date = HijrahChronology.INSTANCE.date(1437, 10, dom);
                  assertEquals(date.getLong(ALIGNED_WEEK_OF_MONTH), ((dom - 1) / 7) + 1);
                  assertEquals(date.getLong(ALIGNED_DAY_OF_WEEK_IN_MONTH), ((dom - 1) % 7) + 1);
                  date = date.plus(1, ChronoUnit.DAYS);
              }
          }

      Spotted by Martin Baker:
      https://github.com/ThreeTen/threetenbp/pull/47
      https://github.com/kemokid

        Attachments

          Activity

            People

            • Assignee:
              ameena Anubhav Meena (Inactive)
              Reporter:
              scolebourne Stephen Colebourne
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: