The HijrahChronology follows the rules of the Hijrah calendar system. The Hijrah calendar has several variants based on differences in when the new moon is determined to have occurred and where the observation is made. In some variants the length of each month is computed algorithmically from the astronomical data for the moon and earth and in others the length of the month is determined by an authorized sighting of the new moon. For the algorithmically based calendars the calendar can project into the future. For sighting based calendars only historical data from past sightings is available.
The length of each month is 29 or 30 days. Ordinary years have 354 days; leap years have 355 days.
CLDR and LDML identify variants:
Chronology ID | Calendar Type | Locale extension, see java. |
Description |
---|---|---|---|
Hijrah-umalqura | islamic-umalqura | ca-islamic-umalqura | Islamic - Umm Al-Qura calendar of Saudi Arabia |
Additional variants may be available through Chronology#getAvailableChronologies()
.
Example
Selecting the chronology from the locale uses Chronology#ofLocale
to find the Chronology based on Locale supported BCP 47 extension mechanism
to request a specific calendar ("ca"). For example,
Locale locale = Locale.forLanguageTag("en-US-u-ca-islamic-umalqura"); Chronology chrono = Chronology.ofLocale(locale);
Implementation Specification
This class is immutable and thread-safe.
Implementation Note
Each Hijrah variant is configured individually. Each variant is defined by a
property resource that defines the ID
, the calendar type
,
the start of the calendar, the alignment with the
ISO calendar, and the length of each month for a range of years.
The variants are loaded by HijrahChronology as a resource from
hijrah-config-<calendar type>.properties.
The Hijrah property resource is a set of properties that describe the calendar.
The syntax is defined by java.util.Properties#load(Reader)
.
Property Name | Property value | Description |
---|---|---|
id | Chronology Id, for example, "Hijrah-umalqura" | The Id of the calendar in common usage |
type | Calendar type, for example, "islamic-umalqura" | LDML defines the calendar types |
version | Version, for example: "1.8.0_1" | The version of the Hijrah variant data |
iso-start | ISO start date, formatted as yyyy-MM-dd , for example: "1900-04-30" |
The ISO date of the first day of the minimum Hijrah year. |
yyyy - a numeric 4 digit year, for example "1434" | The value is a sequence of 12 month lengths, for example: "29 30 29 30 29 30 30 30 29 30 29 29" | The lengths of the 12 months of the year separated by whitespace. A numeric year property must be present for every year without any gaps. The month lengths must be between 29-32 inclusive. |
Additional variants may be added by providing configuration properties files in
<JAVA_HOME>/conf/chronology
directory. The properties
files should follow the naming convention of
hijrah-config-<chronology id>_<calendar type>.properties
.
Modifier and Type | Field and Description |
---|---|
private final transient String | calendarType
The Hijrah calendarType. |
private static final Path | |
private transient int[] | hijrahEpochMonthStartDays
Array of epoch days indexed by Hijrah Epoch month. |
private transient int | hijrahStartEpochMonth
The minimum epoch month. |
private transient volatile boolean | initComplete
Flag to indicate the initialization of configuration data is complete. |
public static final HijrahChronology | INSTANCE
Singleton instance of the Islamic Umm Al-Qura calendar of Saudi Arabia. |
private static final String | |
private static final String | |
private static final String | |
private static final String | |
private transient int | maxEpochDay
The maximum epoch day for which calendar data is available. |
private transient int | maxMonthLength
The maximum length of a month. |
private transient int | maxYearLength
The maximum length of a year in days. |
private transient int | minEpochDay
The minimum epoch day of this Hijrah calendar. |
private transient int | minMonthLength
The minimum length of a month. |
private transient int | minYearLength
The minimum length of a year in days. |
private static final String | RESOURCE_PREFIX
Prefix of resource names for Hijrah calendar variants. |
private static final String | RESOURCE_SUFFIX
Suffix of resource names for Hijrah calendar variants. |
private static final long | serialVersionUID
Serialization version. |
private final transient String | typeId
The Hijrah Calendar id. |
Access | Constructor and Description |
---|---|
private | HijrahChronology(String
the id of the calendar id, String the typeId of the calendar calType)Create a HijrahChronology for the named variant and type. |
Modifier and Type | Method and Description |
---|---|
private void | |
pack-priv void | |
pack-priv void | |
pack-priv int | |
private int[] | Returns: array of epochDays for each month from min to maxThe minimum year for which data is provided minYear, int The maximum year for which data is provided maxYear, Map<Integer, int[]> a Map of year to the array of 12 month lengths years)Converts the map of year to month lengths ranging from minYear to maxYear into a linear contiguous array of epochDays. |
public HijrahDate | Returns: the Hijrah local date, not nullthe Hijrah era, not null era, int the year-of-era yearOfEra, int the month-of-year month, int the day-of-month dayOfMonth)Overrides default java. Obtains a local date in Hijrah calendar system from the era, year-of-era, month-of-year and day-of-month fields. |
public HijrahDate | Returns: the Hijrah local date, not nullthe proleptic-year prolepticYear, int the month-of-year month, int the day-of-month dayOfMonth)Implements java. Obtains a local date in Hijrah calendar system from the proleptic-year, month-of-year and day-of-month fields. |
public HijrahDate | date(TemporalAccessor
the temporal object to convert, not null temporal)Implements java. Obtains a local date in this chronology from another temporal object. |
public HijrahDate | Returns: the Hijrah local date, not nullthe epoch day epochDay)Implements java. Obtains a local date in the Hijrah calendar system from the epoch-day. |
public HijrahDate | dateNow()
Overrides default java. Obtains the current local date in this chronology from the system clock in the default time-zone. |
public HijrahDate | dateNow(ZoneId
the zone ID to use, not null zone)Overrides default java. Obtains the current local date in this chronology from the system clock in the specified time-zone. |
public HijrahDate | dateNow(Clock
the clock to use, not null clock)Overrides default java. Obtains the current local date in this chronology from the specified clock. |
public HijrahDate | Returns: the Hijrah local date, not nullthe Hijrah era, not null era, int the year-of-era yearOfEra, int the day-of-year dayOfYear)Overrides default java. Obtains a local date in Hijrah calendar system from the era, year-of-era and day-of-year fields. |
public HijrahDate | Returns: the Hijrah local date, not nullthe proleptic-year prolepticYear, int the day-of-year dayOfYear)Implements java. Obtains a local date in Hijrah calendar system from the proleptic-year and day-of-year fields. |
private int | Returns: The index of the element of the start of the month containing the epochDay.Returns the epochMonth found by locating the epochDay in the table. |
private int | Returns: the length in days of the epochMonththe epochMonth; assumed to be within range epochMonth)Returns the length of the epochMonth. |
private int | Returns: the epochDay for the start of the epochMonth.the epochMonth epochMonth)Returns the epochDay for the start of the epochMonth. |
private int | Returns: the month of the Hijrah Yearthe epochMonth epochMonth)Returns the Hijrah month from the epochMonth. |
private int | Returns: the Hijrah Yearthe epochMonth epochMonth)Returns the year computed from the epochMonth |
public HijrahEra | Returns: the calendar system era, not nullthe era value eraValue)Implements java. Creates the HijrahEra object from the numeric value. |
public List | |
public String | Returns: the calendar system type; non-null if the calendar has a standard type, otherwise nullImplements java. Gets the calendar type of the Islamic calendar. |
pack-priv int | Returns: the day of year, 1-origina proleptic year prolepticYear, int a month, 1-origin month)Returns day of year for the year and month. |
pack-priv long | Returns: the epoch daythe year to represent, 0-origin prolepticYear, int the month-of-year to represent, 1-origin monthOfYear, int the day-of-month to represent, 1-origin dayOfMonth)Return the epoch day computed from Hijrah year, month, and day. |
pack-priv int[] | Returns: int[0] = YEAR, int[1] = MONTH, int[2] = DATEthe EpochDay epochDay)Returns an array containing the Hijrah year, month and day computed from the epoch day. |
public String | Returns: the chronology ID, non-nullImplements java. Gets the ID of the chronology. |
pack-priv int | |
pack-priv int | |
pack-priv int | |
pack-priv int | |
pack-priv int | |
pack-priv int | Returns: the length of the montha proleptic year prolepticYear, int a month, 1-origin. monthOfYear)Returns month length for the year and month. |
pack-priv int | Returns: smallest maximum day-of-yearReturns smallest maximum day-of-year. |
pack-priv int | |
public boolean | isLeapYear(long
the proleptic-year to check, not validated for range prolepticYear)Implements java. Checks if the specified year is a leap year. |
private void | |
public ChronoLocalDateTime | localDateTime(TemporalAccessor
the temporal object to convert, not null temporal)Overrides default java. Obtains a local date-time in this chronology from another temporal object. |
private int[] | Returns: an array of int[12] containing the 12 month lengthsthe value of a year property line)Parses the 12 months lengths from a property value for a specific year. |
private int[] | |
public int | prolepticYear(Era
the era of the correct type for the chronology, not null era, int the chronology year-of-era yearOfEra)Implements java. Calculates the proleptic-year given the era and year-of-era. |
public ValueRange | range(ChronoField
the field to get the range for, not null field)Implements java. Gets the range of valid values for the specified field. |
private static Properties | Returns: a Properties containing the properties read from the resource.the chronology ID of the calendar variant chronologyId, final String the calendarType of the calendar variant calendarType)Return the configuration properties from the resource. |
private void | readObject(ObjectInputStream
the stream to read s)Hides java. Defend against malicious streams. |
private static void | registerCustomChrono()
Look for Hijrah chronology variant properties files in <JAVA_HOME>/conf/chronology directory. |
public HijrahDate | resolveDate(Map<TemporalField, Long>
the map of fields to values, which can be updated, not null fieldValues, ResolverStyle the requested type of resolve, not null resolverStyle)Overrides java. Implements java. Resolves parsed |
pack-priv Object | Returns: the instance ofSer , not nullOverrides java. Writes the Chronology using a dedicated serialized form. |
private int | Returns: the day of year for the start of the month of the yearthe Hijrah year prolepticYear, int the Hijrah month month)Returns the day of year for the requested HijrahYear and month. |
private int | Returns: the epochMonth for the beginning of the year.the HijrahYear year)Returns the epochMonth for the Hijrah Year. |
public ChronoZonedDateTime | zonedDateTime(TemporalAccessor
the temporal object to convert, not null temporal)Overrides default java. Obtains a |
public ChronoZonedDateTime | zonedDateTime(Instant
the instant to create the date-time from, not null instant, ZoneId the time-zone, not null zone)Overrides default java. Obtains a |
calendarType | back to summary |
---|---|
private final transient String calendarType The Hijrah calendarType. |
CONF_PATH | back to summary |
---|---|
private static final Path CONF_PATH |
hijrahEpochMonthStartDays | back to summary |
---|---|
private transient int[] hijrahEpochMonthStartDays Array of epoch days indexed by Hijrah Epoch month.
Computed by |
hijrahStartEpochMonth | back to summary |
---|---|
private transient int hijrahStartEpochMonth The minimum epoch month.
Computed by |
initComplete | back to summary |
---|---|
private transient volatile boolean initComplete Flag to indicate the initialization of configuration data is complete.
|
INSTANCE | back to summary |
---|---|
public static final HijrahChronology INSTANCE Singleton instance of the Islamic Umm Al-Qura calendar of Saudi Arabia.
Other Hijrah chronology variants may be available from
|
KEY_ID | back to summary |
---|---|
private static final String KEY_ID |
KEY_ISO_START | back to summary |
---|---|
private static final String KEY_ISO_START |
KEY_TYPE | back to summary |
---|---|
private static final String KEY_TYPE |
KEY_VERSION | back to summary |
---|---|
private static final String KEY_VERSION |
maxEpochDay | back to summary |
---|---|
private transient int maxEpochDay The maximum epoch day for which calendar data is available.
Computed by |
maxMonthLength | back to summary |
---|---|
private transient int maxMonthLength The maximum length of a month.
Computed by |
maxYearLength | back to summary |
---|---|
private transient int maxYearLength The maximum length of a year in days.
Computed by |
minEpochDay | back to summary |
---|---|
private transient int minEpochDay The minimum epoch day of this Hijrah calendar.
Computed by |
minMonthLength | back to summary |
---|---|
private transient int minMonthLength The minimum length of a month.
Computed by |
minYearLength | back to summary |
---|---|
private transient int minYearLength The minimum length of a year in days.
Computed by |
RESOURCE_PREFIX | back to summary |
---|---|
private static final String RESOURCE_PREFIX Prefix of resource names for Hijrah calendar variants. |
RESOURCE_SUFFIX | back to summary |
---|---|
private static final String RESOURCE_SUFFIX Suffix of resource names for Hijrah calendar variants. |
serialVersionUID | back to summary |
---|---|
private static final long serialVersionUID Serialization version. |
typeId | back to summary |
---|---|
private final transient String typeId The Hijrah Calendar id. |
HijrahChronology | back to summary |
---|---|
private HijrahChronology(String id, String calType) Create a HijrahChronology for the named variant and type.
|
checkCalendarInit | back to summary |
---|---|
private void checkCalendarInit() Check and ensure that the calendar data has been initialized.
The initialization check is performed at the boundary between
public and package methods. If a public calls another public method
a check is not necessary in the caller.
The constructors of HijrahDate call
|
checkValidDayOfYear | back to summary |
---|---|
pack-priv void checkValidDayOfYear(int dayOfYear) |
checkValidMonth | back to summary |
---|---|
pack-priv void checkValidMonth(int month) |
checkValidYear | back to summary |
---|---|
pack-priv int checkValidYear(long prolepticYear) Check the validity of a year.
|
createEpochMonths | back to summary |
---|---|
private int[] createEpochMonths(int epochDay, int minYear, int maxYear, Map<Integer, int[]> years) Converts the map of year to month lengths ranging from minYear to maxYear into a linear contiguous array of epochDays. The index is the hijrahMonth computed from year and month and offset by minYear. The value of each entry is the epochDay corresponding to the first day of the month. |
date | back to summary |
---|---|
public HijrahDate date(Era era, int yearOfEra, int month, int dayOfMonth) Overrides default java. Obtains a local date in Hijrah calendar system from the era, year-of-era, month-of-year and day-of-month fields.
|
date | back to summary |
---|---|
public HijrahDate date(int prolepticYear, int month, int dayOfMonth) Implements java. Obtains a local date in Hijrah calendar system from the proleptic-year, month-of-year and day-of-month fields.
|
date | back to summary |
---|---|
public HijrahDate date(TemporalAccessor temporal) Implements java. Doc from java. Obtains a local date in this chronology from another temporal object.
This obtains a date in this chronology based on the specified temporal.
A
The conversion typically uses the
This method matches the signature of the functional interface
|
dateEpochDay | back to summary |
---|---|
public HijrahDate dateEpochDay(long epochDay) Implements java. Obtains a local date in the Hijrah calendar system from the epoch-day.
|
dateNow | back to summary |
---|---|
public HijrahDate dateNow() Overrides default java. Doc from java. Obtains the current local date in this chronology from the system clock in the default time-zone.
This will query the Using this method will prevent the ability to use an alternate clock for testing because the clock is hard-coded.
|
dateNow | back to summary |
---|---|
public HijrahDate dateNow(ZoneId zone) Overrides default java. Doc from java. Obtains the current local date in this chronology from the system clock in the specified time-zone.
This will query the Using this method will prevent the ability to use an alternate clock for testing because the clock is hard-coded.
|
dateNow | back to summary |
---|---|
public HijrahDate dateNow(Clock clock) Overrides default java. Doc from java. Obtains the current local date in this chronology from the specified clock.
This will query the specified clock to obtain the current date - today.
Using this method allows the use of an alternate clock for testing.
The alternate clock may be introduced using
|
dateYearDay | back to summary |
---|---|
public HijrahDate dateYearDay(Era era, int yearOfEra, int dayOfYear) Overrides default java. Obtains a local date in Hijrah calendar system from the era, year-of-era and day-of-year fields.
|
dateYearDay | back to summary |
---|---|
public HijrahDate dateYearDay(int prolepticYear, int dayOfYear) Implements java. Obtains a local date in Hijrah calendar system from the proleptic-year and day-of-year fields.
|
epochDayToEpochMonth | back to summary |
---|---|
private int epochDayToEpochMonth(int epochDay) Returns the epochMonth found by locating the epochDay in the table. The epochMonth is the index in the table
|
epochMonthLength | back to summary |
---|---|
private int epochMonthLength(int epochMonth) Returns the length of the epochMonth. It is computed from the start of the following month minus the start of the requested month.
|
epochMonthToEpochDay | back to summary |
---|---|
private int epochMonthToEpochDay(int epochMonth) Returns the epochDay for the start of the epochMonth.
|
epochMonthToMonth | back to summary |
---|---|
private int epochMonthToMonth(int epochMonth) Returns the Hijrah month from the epochMonth.
|
epochMonthToYear | back to summary |
---|---|
private int epochMonthToYear(int epochMonth) Returns the year computed from the epochMonth
|
eraOf | back to summary |
---|---|
public HijrahEra eraOf(int eraValue) Implements java. Creates the HijrahEra object from the numeric value. The Hijrah calendar system has only one era covering the proleptic years greater than zero. This method returns the singleton HijrahEra for the value 1.
|
eras | back to summary |
---|---|
public List Implements java. Doc from java. Gets the list of eras for the chronology. Most calendar systems have an era, within which the year has meaning. If the calendar system does not support the concept of eras, an empty list must be returned. |
getCalendarType | back to summary |
---|---|
public String getCalendarType() Implements java. Gets the calendar type of the Islamic calendar.
The calendar type is an identifier defined by the
Unicode Locale Data Markup Language (LDML) specification.
It can be used to lookup the |
getDayOfYear | back to summary |
---|---|
pack-priv int getDayOfYear(int prolepticYear, int month) Returns day of year for the year and month.
|
getEpochDay | back to summary |
---|---|
pack-priv long getEpochDay(int prolepticYear, int monthOfYear, int dayOfMonth) Return the epoch day computed from Hijrah year, month, and day.
|
getHijrahDateInfo | back to summary |
---|---|
pack-priv int[] getHijrahDateInfo(int epochDay) Returns an array containing the Hijrah year, month and day computed from the epoch day.
|
getId | back to summary |
---|---|
public String getId() Implements java. Gets the ID of the chronology.
The ID uniquely identifies the
|
getMaximumDayOfYear | back to summary |
---|---|
pack-priv int getMaximumDayOfYear() Returns maximum day-of-year.
|
getMaximumMonthLength | back to summary |
---|---|
pack-priv int getMaximumMonthLength() Returns maximum day-of-month.
|
getMaximumYear | back to summary |
---|---|
pack-priv int getMaximumYear() Return the maximum supported Hijrah year.
|
getMinimumMonthLength | back to summary |
---|---|
pack-priv int getMinimumMonthLength() Returns smallest maximum day-of-month.
|
getMinimumYear | back to summary |
---|---|
pack-priv int getMinimumYear() Return the minimum supported Hijrah year.
|
getMonthLength | back to summary |
---|---|
pack-priv int getMonthLength(int prolepticYear, int monthOfYear) Returns month length for the year and month.
|
getSmallestMaximumDayOfYear | back to summary |
---|---|
pack-priv int getSmallestMaximumDayOfYear() Returns smallest maximum day-of-year.
|
getYearLength | back to summary |
---|---|
pack-priv int getYearLength(int prolepticYear) Returns year length. Note The 12th month must exist in the data.
|
isLeapYear | back to summary |
---|---|
public boolean isLeapYear(long prolepticYear) Implements java. Doc from java. Checks if the specified year is a leap year. A leap-year is a year of a longer length than normal. The exact meaning is determined by the chronology according to the following constraints.
Outside the range of valid years an implementation is free to return either a best guess or false. An implementation must not throw an exception, even if the year is outside the range of valid years.
|
loadCalendarData | back to summary |
---|---|
private void loadCalendarData() Loads and processes the Hijrah calendar properties file for this calendarType. The starting Hijrah date and the corresponding ISO date are extracted and used to calculate the epochDate offset. The version number is identified and ignored. Everything else is the data for a year with containing the length of each of 12 months.
|
localDateTime | back to summary |
---|---|
public ChronoLocalDateTime Overrides default java. Doc from java. Obtains a local date-time in this chronology from another temporal object.
This obtains a date-time in this chronology based on the specified temporal.
A
The conversion extracts and combines the
This method matches the signature of the functional interface
|
parseMonths | back to summary |
---|---|
private int[] parseMonths(String line) Parses the 12 months lengths from a property value for a specific year.
|
parseYMD | back to summary |
---|---|
private int[] parseYMD(String string) Parse yyyy-MM-dd into a 3 element array [yyyy, mm, dd].
|
prolepticYear | back to summary |
---|---|
public int prolepticYear(Era era, int yearOfEra) Implements java. Doc from java. Calculates the proleptic-year given the era and year-of-era. This combines the era and year-of-era into the single proleptic-year field.
If the chronology makes active use of eras, such as |
range | back to summary |
---|---|
public ValueRange range(ChronoField field) Implements java. Doc from java. Gets the range of valid values for the specified field.
All fields can be expressed as a Note that the result only describes the minimum and maximum valid values and it is important not to read too much into them. For example, there could be values within the range that are invalid for the field. This method will return a result whether or not the chronology supports the field.
|
readConfigProperties | back to summary |
---|---|
private static Properties readConfigProperties(final String chronologyId, final String calendarType) throws Exception Return the configuration properties from the resource. The location of the variant configuration resource is: "/java/time/chrono/" (for "islamic-umalqura" type), or "
|
readObject | back to summary |
---|---|
private void readObject(ObjectInputStream s) throws InvalidObjectException Hides java. Defend against malicious streams.
|
registerCustomChrono | back to summary |
---|---|
private static void registerCustomChrono() Look for Hijrah chronology variant properties files in <JAVA_HOME>/conf/chronology directory. Then register its chronology, if any.
|
resolveDate | back to summary |
---|---|
public HijrahDate resolveDate(Map<TemporalField, Long> fieldValues, ResolverStyle resolverStyle) Overrides java. Implements java. Doc from java. Resolves parsed
Most
The default implementation is suitable for most calendar systems.
If
|
writeReplace | back to summary |
---|---|
pack-priv Object writeReplace() Overrides java. Writes the Chronology using a dedicated serialized form. |
yearMonthToDayOfYear | back to summary |
---|---|
private int yearMonthToDayOfYear(int prolepticYear, int month) Returns the day of year for the requested HijrahYear and month.
|
yearToEpochMonth | back to summary |
---|---|
private int yearToEpochMonth(int year) Returns the epochMonth for the Hijrah Year.
|
zonedDateTime | back to summary |
---|---|
public ChronoZonedDateTime Overrides default java. Doc from java. Obtains a
This obtains a zoned date-time in this chronology based on the specified temporal.
A
The conversion will first obtain a
This method matches the signature of the functional interface
|
zonedDateTime | back to summary |
---|---|
public ChronoZonedDateTime Overrides default java. Doc from java. Obtains a This obtains a zoned date-time with the same instant as that specified.
|