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

HijrahDate aligned day of week incorrect

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 9
    • 8, 9
    • core-libs
    • None
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: