Sorry for late answer although the solution is already available since end of July 2017 in release v4.28/3.33. (I am now busy with overnext release v4.29/3.34 (sunrise/sunset-calculations)).
Every month-based calendar (including the HijriCalendar
) supports a WEEKDAY_IN_MONTH-element since Time4A-version v3.33-2017b. It is chronology-specific because the month definition is different for every calendar. Example:
HijriCalendar hijri =
HijriCalendar.of(
HijriCalendar.VARIANT_UMALQURA, 1395, HijriMonth.RAMADAN, 1); // Sunday, 1975-09-07
assertThat(
hijri.with(HijriCalendar.WEEKDAY_IN_MONTH.setTo(3, Weekday.WEDNESDAY)),
is(hijri.plus(17, HijriCalendar.Unit.DAYS))); // AH-1395-09-18
More examples how to use the new element can be found in the JUnit-test. The new element can also be used in format patterns with the CLDR-pattern-symbol "F". I show both the builder- and the pattern-based approach:
ChronoFormatter<HijriCalendar> f1 =
ChronoFormatter.setUp(HijriCalendar.family(), Locale.ENGLISH)
.addEnglishOrdinal(HijriCalendar.WEEKDAY_IN_MONTH)
.addPattern(" EEEE 'in' MMMM", PatternType.CLDR)
.build();
assertThat(f1.format(hijri), is("1st Sunday in Ramadan"));
ChronoFormatter<HijriCalendar> f2 =
ChronoFormatter.ofPattern(
"F. EEEE 'im' MMMM",
PatternType.CLDR,
Locale.GERMAN,
HijriCalendar.family());
assertThat(f2.format(hijri), is("1. Sonntag im Ramadan"));
Side note: The new FrenchRepublicanCalendar
(also introduced in v4.28/3.33) has no support for WEEKDAY_IN_MONTH because a) it uses a 10-day-week and b) some days (the sansculottides) are not part of any month.