@CalendarType(value="islamic") public final class HijriCalendar extends CalendarVariant<HijriCalendar>
Represents the Hijri calendar used in many islamic countries.
It is a lunar calendar which exists in several variants and is mainly for religious purposes. The variant used in Saudi-Arabia is named "islamic-umalqura" and is based on data partially observed by sighting the new moon, partially by astronomical calculations/predictions. Note that the religious authorities in most countries often publish dates which deviate from such official calendars by one or two days.
The calendar year is divided into 12 islamic months. Every month usually has either 29 or 30 days. The length of the month in days shall reflect the date when the new moon appears. However, for every variant there are different data or rules how to determine if a month has 29 or 30 days. The Hijri calendar day starts in the evening. New variants can be configured by a file named "{variant-name}.data" in the data-subdirectory of resource class path (where hyphens are replaced by underscores). Format details see the file "islamic_umalqura.data".
Following elements which are declared as constants are registered by this class:
Furthermore, all elements defined in EpochDays are supported.
Example of usage:
ChronoFormatter<HijriCalendar> formatter =
ChronoFormatter.setUp(HijriCalendar.class, Locale.ENGLISH)
.addPattern("EEE, d. MMMM yy", PatternType.NON_ISO_DATE).build()
.withCalendarVariant(HijriCalendar.VARIANT_UMALQURA)
.with(Attributes.PIVOT_YEAR, 1500); // mapped to range 1400-1499
HijriCalendar hijri = formatter.parse("Thu, 29. Ramadan 36");
PlainDate date = hijri.transform(PlainDate.class);
System.out.println(date); // 2015-07-16
Note: This class is still in experimental status. The serialization format will change in future.
| Modifier and Type | Field and Description |
|---|---|
static StdCalendarElement<java.lang.Integer,HijriCalendar> |
DAY_OF_MONTH
Represents the islamic day of month.
|
static StdCalendarElement<Weekday,HijriCalendar> |
DAY_OF_WEEK
Represents the islamic day of week.
|
static StdCalendarElement<java.lang.Integer,HijriCalendar> |
DAY_OF_YEAR
Represents the islamic day of year.
|
static TextElement<HijriEra> |
ERA
Represents the islamic era.
|
static StdCalendarElement<HijriMonth,HijriCalendar> |
MONTH_OF_YEAR
Represents the islamic month.
|
static java.lang.String |
VARIANT_ICU4J
The name of the astronomical ICU4J-variant.
|
static java.lang.String |
VARIANT_UMALQURA
The name of Umm-al-qura-variant.
|
static StdCalendarElement<java.lang.Integer,HijriCalendar> |
YEAR_OF_ERA
Represents the islamic year.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object obj)
Compares the whole state of this instance with given object.
|
static CalendarFamily<HijriCalendar> |
family()
Returns the associated calendar family.
|
int |
getDayOfMonth()
Yields the islamic day of month.
|
Weekday |
getDayOfWeek()
Determines the day of week.
|
int |
getDayOfYear()
Yields the islamic day of year.
|
HijriEra |
getEra()
Yields the islamic era.
|
HijriMonth |
getMonth()
Yields the islamic month.
|
java.lang.String |
getVariant()
Returns the name of the associated variant of underlying calendar system.
|
int |
getYear()
Yields the islamic year.
|
int |
hashCode()
Subclasses must redefine this method corresponding to the
behaviour of
equals(). |
int |
lengthOfMonth()
Yields the length of current islamic month in days.
|
int |
lengthOfYear()
Yields the length of current islamic year in days.
|
HijriCalendar |
nextDay()
Convenient short form for
with(DAY_OF_MONTH.incremented()). |
HijriCalendar |
nextMonth()
Convenient short form for
with(MONTH_OF_YEAR.incremented()). |
HijriCalendar |
nextYear()
Convenient short form for
with(YEAR_OF_ERA.incremented()). |
static HijriCalendar |
of(java.lang.String variant,
int hyear,
HijriMonth hmonth,
int hdom)
Creates a new instance of a Hijri calendar date in given variant.
|
static HijriCalendar |
of(java.lang.String variant,
int hyear,
int hmonth,
int hdom)
Creates a new instance of a Hijri calendar date in given variant.
|
static HijriCalendar |
of(VariantSource variantSource,
int hyear,
HijriMonth hmonth,
int hdom)
Creates a new instance of a Hijri calendar date in given variant.
|
static HijriCalendar |
of(VariantSource variantSource,
int hyear,
int hmonth,
int hdom)
Creates a new instance of a Hijri calendar date in given variant.
|
static HijriCalendar |
ofUmalqura(int hyear,
HijriMonth hmonth,
int hdom)
Creates a new instance of a Hijri calendar date in the variant "islamic-umalqura"
used in Saudi-Arabia.
|
static HijriCalendar |
ofUmalqura(int hyear,
int hmonth,
int hdom)
Creates a new instance of a Hijri calendar date in the variant "islamic-umalqura"
used in Saudi-Arabia.
|
java.lang.String |
toString()
Provides a complete textual representation of the state of this calendar variant.
|
compareTo, isAfter, isBefore, isSimultaneous, minus, plus, transform, transform, transformcontains, get, get, getMaximum, getMinimum, getTimezone, hasTimezone, isValid, isValid, isValid, matches, with, with, with, with@FormattableElement(format="G") public static final TextElement<HijriEra> ERA
Represents the islamic era.
@FormattableElement(format="y") public static final StdCalendarElement<java.lang.Integer,HijriCalendar> YEAR_OF_ERA
Represents the islamic year.
@FormattableElement(format="M", standalone="L") public static final StdCalendarElement<HijriMonth,HijriCalendar> MONTH_OF_YEAR
Represents the islamic month.
@FormattableElement(format="d") public static final StdCalendarElement<java.lang.Integer,HijriCalendar> DAY_OF_MONTH
Represents the islamic day of month.
@FormattableElement(format="D") public static final StdCalendarElement<java.lang.Integer,HijriCalendar> DAY_OF_YEAR
Represents the islamic day of year.
@FormattableElement(format="E") public static final StdCalendarElement<Weekday,HijriCalendar> DAY_OF_WEEK
Represents the islamic day of week.
If the day-of-week is set to a new value then Time4J handles the islamic calendar week as starting on Sunday.
public static final java.lang.String VARIANT_UMALQURA
The supported range of islamic years is 1300-1500.
public static final java.lang.String VARIANT_ICU4J
The supported range of islamic years is 1-1600.
public static HijriCalendar of(java.lang.String variant, int hyear, HijriMonth hmonth, int hdom)
Creates a new instance of a Hijri calendar date in given variant.
variant - calendar varianthyear - islamic yearhmonth - islamic monthhdom - islamic day of monthHijriCalendarChronoException - if given variant is not supportedjava.lang.IllegalArgumentException - in case of any inconsistenciespublic static HijriCalendar of(java.lang.String variant, int hyear, int hmonth, int hdom)
Creates a new instance of a Hijri calendar date in given variant.
variant - calendar varianthyear - islamic yearhmonth - islamic monthhdom - islamic day of monthHijriCalendarChronoException - if given variant is not supportedjava.lang.IllegalArgumentException - in case of any inconsistenciespublic static HijriCalendar of(VariantSource variantSource, int hyear, HijriMonth hmonth, int hdom)
Creates a new instance of a Hijri calendar date in given variant.
variantSource - source of calendar varianthyear - islamic yearhmonth - islamic monthhdom - islamic day of monthHijriCalendarChronoException - if given variant is not supportedjava.lang.IllegalArgumentException - in case of any inconsistenciespublic static HijriCalendar of(VariantSource variantSource, int hyear, int hmonth, int hdom)
Creates a new instance of a Hijri calendar date in given variant.
variantSource - source of calendar varianthyear - islamic yearhmonth - islamic monthhdom - islamic day of monthHijriCalendarChronoException - if given variant is not supportedjava.lang.IllegalArgumentException - in case of any inconsistenciespublic static HijriCalendar ofUmalqura(int hyear, HijriMonth hmonth, int hdom)
Creates a new instance of a Hijri calendar date in the variant "islamic-umalqura" used in Saudi-Arabia.
hyear - islamic yearhmonth - islamic monthhdom - islamic day of monthHijriCalendarChronoException - if given variant is not supportedjava.lang.IllegalArgumentException - in case of any inconsistenciespublic static HijriCalendar ofUmalqura(int hyear, int hmonth, int hdom)
Creates a new instance of a Hijri calendar date in the variant "islamic-umalqura" used in Saudi-Arabia.
hyear - islamic yearhmonth - islamic monthhdom - islamic day of monthHijriCalendarChronoException - if given variant is not supportedjava.lang.IllegalArgumentException - in case of any inconsistenciespublic HijriEra getEra()
Yields the islamic era.
HijriEra.ANNO_HEGIRAEpublic int getYear()
Yields the islamic year.
public HijriMonth getMonth()
Yields the islamic month.
public int getDayOfMonth()
Yields the islamic day of month.
public Weekday getDayOfWeek()
Determines the day of week.
The Hijri calendar also uses a 7-day-week.
public int getDayOfYear()
Yields the islamic day of year.
public java.lang.String getVariant()
CalendarVariantReturns the name of the associated variant of underlying calendar system.
getVariant in class CalendarVariant<HijriCalendar>CalendarFamily.getCalendarSystem(String)public int lengthOfMonth()
Yields the length of current islamic month in days.
public int lengthOfYear()
Yields the length of current islamic year in days.
public HijriCalendar nextYear()
Convenient short form for with(YEAR_OF_ERA.incremented()).
public HijriCalendar nextMonth()
Convenient short form for with(MONTH_OF_YEAR.incremented()).
public HijriCalendar nextDay()
Convenient short form for with(DAY_OF_MONTH.incremented()).
public boolean equals(java.lang.Object obj)
CalendarVariantCompares the whole state of this instance with given object.
Implementations will usually define their state based on the temporal position and the variant name. Exceptions from this rule should be explicitly documented and reasoned.
equals in class CalendarVariant<HijriCalendar>CalendarVariant.compareTo(CalendarVariant)public int hashCode()
CalendarVariantSubclasses must redefine this method corresponding to the
behaviour of equals().
hashCode in class CalendarVariant<HijriCalendar>public java.lang.String toString()
CalendarVariantProvides a complete textual representation of the state of this calendar variant.
toString in class CalendarVariant<HijriCalendar>public static CalendarFamily<HijriCalendar> family()
Returns the associated calendar family.