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

        Activity

        Hide
        hgupdate HG Updates added a comment -
        URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/160db4882087
        User: rchamyal
        Date: 2016-10-21 09:22:49 +0000
        Show
        hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/160db4882087 User: rchamyal Date: 2016-10-21 09:22:49 +0000
        Hide
        hgupdate HG Updates added a comment -
        URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/160db4882087
        User: lana
        Date: 2016-10-26 20:16:10 +0000
        Show
        hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/160db4882087 User: lana Date: 2016-10-26 20:16:10 +0000

          People

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

            Dates

            • Created:
              Updated:
              Resolved: