Top Description Fields Constructors Methods
java.time.chrono

public final Class HijrahChronology

extends AbstractChronology
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Static Imports
java.time.temporal.ChronoField.EPOCH_DAY

The Hijrah calendar is a lunar calendar supporting Islamic calendars.

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:

Variants of Hijrah Calendars
Chronology ID Calendar Type Locale extension, see java.util.Locale 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).

Configuration of Hijrah Calendar
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.

Since
1.8

Field Summary

Modifier and TypeField 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.

Constructor Summary

AccessConstructor 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.

Method Summary

Modifier and TypeMethod and Description
private void
checkCalendarInit()

Check and ensure that the calendar data has been initialized.

pack-priv void
checkValidDayOfYear(int dayOfYear)

pack-priv void
checkValidMonth(int month)

pack-priv int
checkValidYear(long
the year to check
prolepticYear
)

Check the validity of a year.

private int[]

Returns:

array of epochDays for each month from min to max
createEpochMonths
(int epochDay, int
The 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 null
date
(Era
the 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.time.chrono.Chronology.date.

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 null
date
(int
the proleptic-year
prolepticYear
,
int
the month-of-year
month
,
int
the day-of-month
dayOfMonth
)

Implements java.time.chrono.Chronology.date.

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.time.chrono.Chronology.date.

Obtains a local date in this chronology from another temporal object.

public HijrahDate

Returns:

the Hijrah local date, not null
dateEpochDay
(long
the epoch day
epochDay
)

Implements java.time.chrono.Chronology.dateEpochDay.

Obtains a local date in the Hijrah calendar system from the epoch-day.

public HijrahDate
dateNow()

Overrides default java.time.chrono.Chronology.dateNow.

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.time.chrono.Chronology.dateNow.

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.time.chrono.Chronology.dateNow.

Obtains the current local date in this chronology from the specified clock.

public HijrahDate

Returns:

the Hijrah local date, not null
dateYearDay
(Era
the Hijrah era, not null
era
,
int
the year-of-era
yearOfEra
,
int
the day-of-year
dayOfYear
)

Overrides default java.time.chrono.Chronology.dateYearDay.

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 null
dateYearDay
(int
the proleptic-year
prolepticYear
,
int
the day-of-year
dayOfYear
)

Implements java.time.chrono.Chronology.dateYearDay.

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.
epochDayToEpochMonth
(int epochDay)

Returns the epochMonth found by locating the epochDay in the table.

private int

Returns:

the length in days of the epochMonth
epochMonthLength
(int
the epochMonth; assumed to be within range
epochMonth
)

Returns the length of the epochMonth.

private int

Returns:

the epochDay for the start of the epochMonth.
epochMonthToEpochDay
(int
the epochMonth
epochMonth
)

Returns the epochDay for the start of the epochMonth.

private int

Returns:

the month of the Hijrah Year
epochMonthToMonth
(int
the epochMonth
epochMonth
)

Returns the Hijrah month from the epochMonth.

private int

Returns:

the Hijrah Year
epochMonthToYear
(int
the epochMonth
epochMonth
)

Returns the year computed from the epochMonth

public HijrahEra

Returns:

the calendar system era, not null
eraOf
(int
the era value
eraValue
)

Implements java.time.chrono.Chronology.eraOf.

Creates the HijrahEra object from the numeric value.

public List<Era>
eras()

Implements java.time.chrono.Chronology.eras.

Gets the list of eras for the chronology.

public String

Returns:

the calendar system type; non-null if the calendar has a standard type, otherwise null
getCalendarType
()

Implements java.time.chrono.Chronology.getCalendarType.

Gets the calendar type of the Islamic calendar.

pack-priv int

Returns:

the day of year, 1-origin
getDayOfYear
(int
a proleptic year
prolepticYear
,
int
a month, 1-origin
month
)

Returns day of year for the year and month.

pack-priv long

Returns:

the epoch day
getEpochDay
(int
the 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] = DATE
getHijrahDateInfo
(int
the EpochDay
epochDay
)

Returns an array containing the Hijrah year, month and day computed from the epoch day.

public String

Returns:

the chronology ID, non-null
getId
()

Implements java.time.chrono.Chronology.getId.

Gets the ID of the chronology.

pack-priv int

Returns:

maximum day-of-year
getMaximumDayOfYear
()

Returns maximum day-of-year.

pack-priv int

Returns:

maximum day-of-month
getMaximumMonthLength
()

Returns maximum day-of-month.

pack-priv int

Returns:

the minimum
getMaximumYear
()

Return the maximum supported Hijrah year.

pack-priv int

Returns:

smallest maximum day-of-month
getMinimumMonthLength
()

Returns smallest maximum day-of-month.

pack-priv int

Returns:

the minimum
getMinimumYear
()

Return the minimum supported Hijrah year.

pack-priv int

Returns:

the length of the month
getMonthLength
(int
a 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-year
getSmallestMaximumDayOfYear
()

Returns smallest maximum day-of-year.

pack-priv int

Returns:

year length in days
getYearLength
(int
a proleptic year
prolepticYear
)

Returns year length.

public boolean
isLeapYear(long
the proleptic-year to check, not validated for range
prolepticYear
)

Implements java.time.chrono.Chronology.isLeapYear.

Checks if the specified year is a leap year.

private void
loadCalendarData()

Loads and processes the Hijrah calendar properties file for this calendarType.

public ChronoLocalDateTime<HijrahDate>
localDateTime(TemporalAccessor
the temporal object to convert, not null
temporal
)

Overrides default java.time.chrono.Chronology.localDateTime.

Obtains a local date-time in this chronology from another temporal object.

private int[]

Returns:

an array of int[12] containing the 12 month lengths
parseMonths
(String
the value of a year property
line
)

Parses the 12 months lengths from a property value for a specific year.

private int[]

Returns:

the 3 element array with year, month, day
parseYMD
(String
the input string
string
)

Parse yyyy-MM-dd into a 3 element array [yyyy, mm, dd].

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.time.chrono.Chronology.prolepticYear.

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.time.chrono.Chronology.range.

Gets the range of valid values for the specified field.

private static Properties

Returns:

a Properties containing the properties read from the resource.
readConfigProperties
(final String
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.time.chrono.AbstractChronology.readObject.

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.time.chrono.AbstractChronology.resolveDate.

Implements java.time.chrono.Chronology.resolveDate.

Resolves parsed ChronoField values into a date during parsing.

pack-priv Object

Returns:

the instance of Ser, not null
writeReplace
()

Overrides java.time.chrono.AbstractChronology.writeReplace.

Writes the Chronology using a dedicated serialized form.

private int

Returns:

the day of year for the start of the month of the year
yearMonthToDayOfYear
(int
the 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.
yearToEpochMonth
(int
the HijrahYear
year
)

Returns the epochMonth for the Hijrah Year.

public ChronoZonedDateTime<HijrahDate>
zonedDateTime(TemporalAccessor
the temporal object to convert, not null
temporal
)

Overrides default java.time.chrono.Chronology.zonedDateTime.

Obtains a ChronoZonedDateTime in this chronology from another temporal object.

public ChronoZonedDateTime<HijrahDate>
zonedDateTime(Instant
the instant to create the date-time from, not null
instant
,
ZoneId
the time-zone, not null
zone
)

Overrides default java.time.chrono.Chronology.zonedDateTime.

Obtains a ChronoZonedDateTime in this chronology from an Instant.

Inherited from java.time.chrono.AbstractChronology:
addFieldValuecompareToequalsgetAvailableChronologieshashCodeofofLocalereadExternalregisterChronoregisterChronoresolveAlignedresolveProlepticMonthresolveYAAresolveYADresolveYDresolveYearOfEraresolveYMAAresolveYMADresolveYMDtoStringwriteExternal

Field Detail

calendarTypeback to summary
private final transient String calendarType

The Hijrah calendarType.

CONF_PATHback to summary
private static final Path CONF_PATH
hijrahEpochMonthStartDaysback to summary
private transient int[] hijrahEpochMonthStartDays

Array of epoch days indexed by Hijrah Epoch month. Computed by loadCalendarData.

hijrahStartEpochMonthback to summary
private transient int hijrahStartEpochMonth

The minimum epoch month. Computed by loadCalendarData.

initCompleteback to summary
private transient volatile boolean initComplete

Flag to indicate the initialization of configuration data is complete.

See Also
checkCalendarInit()
INSTANCEback 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 Chronology#getAvailableChronologies.

KEY_IDback to summary
private static final String KEY_ID
KEY_ISO_STARTback to summary
private static final String KEY_ISO_START
KEY_TYPEback to summary
private static final String KEY_TYPE
KEY_VERSIONback to summary
private static final String KEY_VERSION
maxEpochDayback to summary
private transient int maxEpochDay

The maximum epoch day for which calendar data is available. Computed by loadCalendarData.

maxMonthLengthback to summary
private transient int maxMonthLength

The maximum length of a month. Computed by createEpochMonths.

maxYearLengthback to summary
private transient int maxYearLength

The maximum length of a year in days. Computed by createEpochMonths.

minEpochDayback to summary
private transient int minEpochDay

The minimum epoch day of this Hijrah calendar. Computed by loadCalendarData.

minMonthLengthback to summary
private transient int minMonthLength

The minimum length of a month. Computed by createEpochMonths.

minYearLengthback to summary
private transient int minYearLength

The minimum length of a year in days. Computed by createEpochMonths.

RESOURCE_PREFIXback to summary
private static final String RESOURCE_PREFIX

Prefix of resource names for Hijrah calendar variants.

RESOURCE_SUFFIXback to summary
private static final String RESOURCE_SUFFIX

Suffix of resource names for Hijrah calendar variants.

serialVersionUIDback to summary
private static final long serialVersionUID

Serialization version.

Annotations
@Serial
typeIdback to summary
private final transient String typeId

The Hijrah Calendar id.

Constructor Detail

HijrahChronologyback to summary
private HijrahChronology(String id, String calType)

Create a HijrahChronology for the named variant and type.

Parameters
id:String

the id of the calendar

calType:String

the typeId of the calendar

Exceptions
IllegalArgumentException:
if the id or typeId is empty

Method Detail

checkCalendarInitback 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 getEpochDay or getHijrahDateInfo so every call from HijrahDate to a HijrahChronology via package private methods has been checked.

Exceptions
DateTimeException:
if the calendar data configuration is malformed or IOExceptions occur loading the data
checkValidDayOfYearback to summary
pack-priv void checkValidDayOfYear(int dayOfYear)
checkValidMonthback to summary
pack-priv void checkValidMonth(int month)
checkValidYearback to summary
pack-priv int checkValidYear(long prolepticYear)

Check the validity of a year.

Parameters
prolepticYear:long

the year to check

createEpochMonthsback 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.

Parameters
minYear:int

The minimum year for which data is provided

maxYear:int

The maximum year for which data is provided

years:Map<Integer, int[]>

a Map of year to the array of 12 month lengths

Returns:int[]

array of epochDays for each month from min to max

dateback to summary
public HijrahDate date(Era era, int yearOfEra, int month, int dayOfMonth)

Overrides default java.time.chrono.Chronology.date.

Obtains a local date in Hijrah calendar system from the era, year-of-era, month-of-year and day-of-month fields.

Parameters
era:Era

the Hijrah era, not null

yearOfEra:int

the year-of-era

month:int

the month-of-year

dayOfMonth:int

the day-of-month

Returns:HijrahDate

the Hijrah local date, not null

Annotations
@Override
Exceptions
DateTimeException:
if unable to create the date
ClassCastException:
if the era is not a HijrahEra
dateback to summary
public HijrahDate date(int prolepticYear, int month, int dayOfMonth)

Implements java.time.chrono.Chronology.date.

Obtains a local date in Hijrah calendar system from the proleptic-year, month-of-year and day-of-month fields.

Parameters
prolepticYear:int

the proleptic-year

month:int

the month-of-year

dayOfMonth:int

the day-of-month

Returns:HijrahDate

the Hijrah local date, not null

Annotations
@Override
Exceptions
DateTimeException:
if unable to create the date
dateback to summary
public HijrahDate date(TemporalAccessor temporal)

Implements java.time.chrono.Chronology.date.

Doc from java.time.chrono.Chronology.date.

Obtains a local date in this chronology from another temporal object.

This obtains a date in this chronology based on the specified temporal. A TemporalAccessor represents an arbitrary set of date and time information, which this factory converts to an instance of ChronoLocalDate.

The conversion typically uses the EPOCH_DAY field, which is standardized across calendar systems.

This method matches the signature of the functional interface TemporalQuery allowing it to be used as a query via method reference, aChronology::date.

Parameters
temporal:TemporalAccessor

the temporal object to convert, not null

Returns:HijrahDate

the local date in this chronology, not null

Annotations
@Override
dateEpochDayback to summary
public HijrahDate dateEpochDay(long epochDay)

Implements java.time.chrono.Chronology.dateEpochDay.

Obtains a local date in the Hijrah calendar system from the epoch-day.

Parameters
epochDay:long

the epoch day

Returns:HijrahDate

the Hijrah local date, not null

Annotations
@Override
Exceptions
DateTimeException:
if unable to create the date
dateNowback to summary
public HijrahDate dateNow()

Overrides default java.time.chrono.Chronology.dateNow.

Doc from java.time.chrono.Chronology.dateNow.

Obtains the current local date in this chronology from the system clock in the default time-zone.

This will query the system clock in the default time-zone to obtain the current date.

Using this method will prevent the ability to use an alternate clock for testing because the clock is hard-coded.

Returns:HijrahDate

the current local date using the system clock and default time-zone, not null

Annotations
@Override
dateNowback to summary
public HijrahDate dateNow(ZoneId zone)

Overrides default java.time.chrono.Chronology.dateNow.

Doc from java.time.chrono.Chronology.dateNow.

Obtains the current local date in this chronology from the system clock in the specified time-zone.

This will query the system clock to obtain the current date. Specifying the time-zone avoids dependence on the default time-zone.

Using this method will prevent the ability to use an alternate clock for testing because the clock is hard-coded.

Parameters
zone:ZoneId

the zone ID to use, not null

Returns:HijrahDate

the current local date using the system clock, not null

Annotations
@Override
dateNowback to summary
public HijrahDate dateNow(Clock clock)

Overrides default java.time.chrono.Chronology.dateNow.

Doc from java.time.chrono.Chronology.dateNow.

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 dependency injection.

Parameters
clock:Clock

the clock to use, not null

Returns:HijrahDate

the current local date, not null

Annotations
@Override
dateYearDayback to summary
public HijrahDate dateYearDay(Era era, int yearOfEra, int dayOfYear)

Overrides default java.time.chrono.Chronology.dateYearDay.

Obtains a local date in Hijrah calendar system from the era, year-of-era and day-of-year fields.

Parameters
era:Era

the Hijrah era, not null

yearOfEra:int

the year-of-era

dayOfYear:int

the day-of-year

Returns:HijrahDate

the Hijrah local date, not null

Annotations
@Override
Exceptions
DateTimeException:
if unable to create the date
ClassCastException:
if the era is not a HijrahEra
dateYearDayback to summary
public HijrahDate dateYearDay(int prolepticYear, int dayOfYear)

Implements java.time.chrono.Chronology.dateYearDay.

Obtains a local date in Hijrah calendar system from the proleptic-year and day-of-year fields.

Parameters
prolepticYear:int

the proleptic-year

dayOfYear:int

the day-of-year

Returns:HijrahDate

the Hijrah local date, not null

Annotations
@Override
Exceptions
DateTimeException:
if the value of the year is out of range, or if the day-of-year is invalid for the year
epochDayToEpochMonthback 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

Returns:int

The index of the element of the start of the month containing the epochDay.

epochMonthLengthback 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.

Parameters
epochMonth:int

the epochMonth; assumed to be within range

Returns:int

the length in days of the epochMonth

epochMonthToEpochDayback to summary
private int epochMonthToEpochDay(int epochMonth)

Returns the epochDay for the start of the epochMonth.

Parameters
epochMonth:int

the epochMonth

Returns:int

the epochDay for the start of the epochMonth.

epochMonthToMonthback to summary
private int epochMonthToMonth(int epochMonth)

Returns the Hijrah month from the epochMonth.

Parameters
epochMonth:int

the epochMonth

Returns:int

the month of the Hijrah Year

epochMonthToYearback to summary
private int epochMonthToYear(int epochMonth)

Returns the year computed from the epochMonth

Parameters
epochMonth:int

the epochMonth

Returns:int

the Hijrah Year

eraOfback to summary
public HijrahEra eraOf(int eraValue)

Implements java.time.chrono.Chronology.eraOf.

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.

Parameters
eraValue:int

the era value

Returns:HijrahEra

the calendar system era, not null

Annotations
@Override
Exceptions
DateTimeException:
if unable to create the era
erasback to summary
public List<Era> eras()

Implements java.time.chrono.Chronology.eras.

Doc from java.time.chrono.Chronology.eras.

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.

Returns:List<Era>

the list of eras for the chronology, may be immutable, not null

Annotations
@Override
getCalendarTypeback to summary
public String getCalendarType()

Implements java.time.chrono.Chronology.getCalendarType.

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 Chronology using Chronology#of(String).

Returns:String

the calendar system type; non-null if the calendar has a standard type, otherwise null

Annotations
@Override
See Also
getId()
getDayOfYearback to summary
pack-priv int getDayOfYear(int prolepticYear, int month)

Returns day of year for the year and month.

Parameters
prolepticYear:int

a proleptic year

month:int

a month, 1-origin

Returns:int

the day of year, 1-origin

getEpochDayback to summary
pack-priv long getEpochDay(int prolepticYear, int monthOfYear, int dayOfMonth)

Return the epoch day computed from Hijrah year, month, and day.

Parameters
prolepticYear:int

the year to represent, 0-origin

monthOfYear:int

the month-of-year to represent, 1-origin

dayOfMonth:int

the day-of-month to represent, 1-origin

Returns:long

the epoch day

getHijrahDateInfoback to summary
pack-priv int[] getHijrahDateInfo(int epochDay)

Returns an array containing the Hijrah year, month and day computed from the epoch day.

Parameters
epochDay:int

the EpochDay

Returns:int[]

int[0] = YEAR, int[1] = MONTH, int[2] = DATE

getIdback to summary
public String getId()

Implements java.time.chrono.Chronology.getId.

Gets the ID of the chronology.

The ID uniquely identifies the Chronology. It can be used to lookup the Chronology using Chronology#of(String).

Returns:String

the chronology ID, non-null

Annotations
@Override
See Also
getCalendarType()
getMaximumDayOfYearback to summary
pack-priv int getMaximumDayOfYear()

Returns maximum day-of-year.

Returns:int

maximum day-of-year

getMaximumMonthLengthback to summary
pack-priv int getMaximumMonthLength()

Returns maximum day-of-month.

Returns:int

maximum day-of-month

getMaximumYearback to summary
pack-priv int getMaximumYear()

Return the maximum supported Hijrah year.

Returns:int

the minimum

getMinimumMonthLengthback to summary
pack-priv int getMinimumMonthLength()

Returns smallest maximum day-of-month.

Returns:int

smallest maximum day-of-month

getMinimumYearback to summary
pack-priv int getMinimumYear()

Return the minimum supported Hijrah year.

Returns:int

the minimum

getMonthLengthback to summary
pack-priv int getMonthLength(int prolepticYear, int monthOfYear)

Returns month length for the year and month.

Parameters
prolepticYear:int

a proleptic year

monthOfYear:int

a month, 1-origin.

Returns:int

the length of the month

getSmallestMaximumDayOfYearback to summary
pack-priv int getSmallestMaximumDayOfYear()

Returns smallest maximum day-of-year.

Returns:int

smallest maximum day-of-year

getYearLengthback to summary
pack-priv int getYearLength(int prolepticYear)

Returns year length.

Note

The 12th month must exist in the data.

Parameters
prolepticYear:int

a proleptic year

Returns:int

year length in days

isLeapYearback to summary
public boolean isLeapYear(long prolepticYear)

Implements java.time.chrono.Chronology.isLeapYear.

Doc from java.time.chrono.Chronology.isLeapYear.

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.

  • a leap-year must imply a year-length longer than a non leap-year.
  • a chronology that does not support the concept of a year must return false.
  • the correct result must be returned for all years within the valid range of years for the chronology.

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.

Parameters
prolepticYear:long

the proleptic-year to check, not validated for range

Returns:boolean

true if the year is a leap year

Annotations
@Override
loadCalendarDataback 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.

Exceptions
DateTimeException:
if initialization of the calendar data from the resource fails
localDateTimeback to summary
public ChronoLocalDateTime<HijrahDate> localDateTime(TemporalAccessor temporal)

Overrides default java.time.chrono.Chronology.localDateTime.

Doc from java.time.chrono.Chronology.localDateTime.

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 TemporalAccessor represents an arbitrary set of date and time information, which this factory converts to an instance of ChronoLocalDateTime.

The conversion extracts and combines the ChronoLocalDate and the LocalTime from the temporal object. Implementations are permitted to perform optimizations such as accessing those fields that are equivalent to the relevant objects. The result uses this chronology.

This method matches the signature of the functional interface TemporalQuery allowing it to be used as a query via method reference, aChronology::localDateTime.

Parameters
temporal:TemporalAccessor

the temporal object to convert, not null

Returns:ChronoLocalDateTime<HijrahDate>

the local date-time in this chronology, not null

Annotations
@Override
@SuppressWarnings:unchecked
parseMonthsback to summary
private int[] parseMonths(String line)

Parses the 12 months lengths from a property value for a specific year.

Parameters
line:String

the value of a year property

Returns:int[]

an array of int[12] containing the 12 month lengths

Exceptions
IllegalArgumentException:
if the number of months is not 12
NumberFormatException:
if the 12 tokens are not numbers
parseYMDback to summary
private int[] parseYMD(String string)

Parse yyyy-MM-dd into a 3 element array [yyyy, mm, dd].

Parameters
string:String

the input string

Returns:int[]

the 3 element array with year, month, day

prolepticYearback to summary
public int prolepticYear(Era era, int yearOfEra)

Implements java.time.chrono.Chronology.prolepticYear.

Doc from java.time.chrono.Chronology.prolepticYear.

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 JapaneseChronology then the year-of-era will be validated against the era. For other chronologies, validation is optional.

Parameters
era:Era

the era of the correct type for the chronology, not null

yearOfEra:int

the chronology year-of-era

Returns:int

the proleptic-year

Annotations
@Override
rangeback to summary
public ValueRange range(ChronoField field)

Implements java.time.chrono.Chronology.range.

Doc from java.time.chrono.Chronology.range.

Gets the range of valid values for the specified field.

All fields can be expressed as a long integer. This method returns an object that describes the valid range for that value.

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.

Parameters
field:ChronoField

the field to get the range for, not null

Returns:ValueRange

the range of valid values for the field, not null

Annotations
@Override
readConfigPropertiesback 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
  "/conf/chronology/" +
  "hijrah-config-" + chronologyId + "_" + calendarType + ".properties"
Parameters
chronologyId:String

the chronology ID of the calendar variant

calendarType:String

the calendarType of the calendar variant

Returns:Properties

a Properties containing the properties read from the resource.

Exceptions
Exception:
if access to the property resource fails
readObjectback to summary
private void readObject(ObjectInputStream s) throws InvalidObjectException

Hides java.time.chrono.AbstractChronology.readObject.

Defend against malicious streams.

Parameters
s:ObjectInputStream

the stream to read

Annotations
@Serial
Exceptions
InvalidObjectException:
always
registerCustomChronoback 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.

Annotations
@SuppressWarnings:removal
resolveDateback to summary
public HijrahDate resolveDate(Map<TemporalField, Long> fieldValues, ResolverStyle resolverStyle)

Overrides java.time.chrono.AbstractChronology.resolveDate.

Implements java.time.chrono.Chronology.resolveDate.

Doc from java.time.chrono.AbstractChronology.resolveDate.

Resolves parsed ChronoField values into a date during parsing.

Most TemporalField implementations are resolved using the resolve method on the field. By contrast, the ChronoField class defines fields that only have meaning relative to the chronology. As such, ChronoField date fields are resolved here in the context of a specific chronology.

ChronoField instances are resolved by this method, which may be overridden in subclasses.

  • EPOCH_DAY - If present, this is converted to a date and all other date fields are then cross-checked against the date.
  • PROLEPTIC_MONTH - If present, then it is split into the YEAR and MONTH_OF_YEAR. If the mode is strict or smart then the field is validated.
  • YEAR_OF_ERA and ERA - If both are present, then they are combined to form a YEAR. In lenient mode, the YEAR_OF_ERA range is not validated, in smart and strict mode it is. The ERA is validated for range in all three modes. If only the YEAR_OF_ERA is present, and the mode is smart or lenient, then the last available era is assumed. In strict mode, no era is assumed and the YEAR_OF_ERA is left untouched. If only the ERA is present, then it is left untouched.
  • YEAR, MONTH_OF_YEAR and DAY_OF_MONTH - If all three are present, then they are combined to form a date. In all three modes, the YEAR is validated. If the mode is smart or strict, then the month and day are validated. If the mode is lenient, then the date is combined in a manner equivalent to creating a date on the first day of the first month in the requested year, then adding the difference in months, then the difference in days. If the mode is smart, and the day-of-month is greater than the maximum for the year-month, then the day-of-month is adjusted to the last day-of-month. If the mode is strict, then the three fields must form a valid date.
  • YEAR and DAY_OF_YEAR - If both are present, then they are combined to form a date. In all three modes, the YEAR is validated. If the mode is lenient, then the date is combined in a manner equivalent to creating a date on the first day of the requested year, then adding the difference in days. If the mode is smart or strict, then the two fields must form a valid date.
  • YEAR, MONTH_OF_YEAR, ALIGNED_WEEK_OF_MONTH and ALIGNED_DAY_OF_WEEK_IN_MONTH - If all four are present, then they are combined to form a date. In all three modes, the YEAR is validated. If the mode is lenient, then the date is combined in a manner equivalent to creating a date on the first day of the first month in the requested year, then adding the difference in months, then the difference in weeks, then in days. If the mode is smart or strict, then the all four fields are validated to their outer ranges. The date is then combined in a manner equivalent to creating a date on the first day of the requested year and month, then adding the amount in weeks and days to reach their values. If the mode is strict, the date is additionally validated to check that the day and week adjustment did not change the month.
  • YEAR, MONTH_OF_YEAR, ALIGNED_WEEK_OF_MONTH and DAY_OF_WEEK - If all four are present, then they are combined to form a date. The approach is the same as described above for years, months and weeks in ALIGNED_DAY_OF_WEEK_IN_MONTH. The day-of-week is adjusted as the next or same matching day-of-week once the years, months and weeks have been handled.
  • YEAR, ALIGNED_WEEK_OF_YEAR and ALIGNED_DAY_OF_WEEK_IN_YEAR - If all three are present, then they are combined to form a date. In all three modes, the YEAR is validated. If the mode is lenient, then the date is combined in a manner equivalent to creating a date on the first day of the requested year, then adding the difference in weeks, then in days. If the mode is smart or strict, then the all three fields are validated to their outer ranges. The date is then combined in a manner equivalent to creating a date on the first day of the requested year, then adding the amount in weeks and days to reach their values. If the mode is strict, the date is additionally validated to check that the day and week adjustment did not change the year.
  • YEAR, ALIGNED_WEEK_OF_YEAR and DAY_OF_WEEK - If all three are present, then they are combined to form a date. The approach is the same as described above for years and weeks in ALIGNED_DAY_OF_WEEK_IN_YEAR. The day-of-week is adjusted as the next or same matching day-of-week once the years and weeks have been handled.

The default implementation is suitable for most calendar systems. If java.time.temporal.ChronoField#YEAR_OF_ERA is found without an java.time.temporal.ChronoField#ERA then the last era in eras() is used. The implementation assumes a 7 day week, that the first day-of-month has the value 1, that first day-of-year has the value 1, and that the first of the month and year always exists.

Parameters
fieldValues:Map<TemporalField, Long>

the map of fields to values, which can be updated, not null

resolverStyle:ResolverStyle

the requested type of resolve, not null

Returns:HijrahDate

the resolved date, null if insufficient information to create a date

Annotations
@Override
writeReplaceback to summary
pack-priv Object writeReplace()

Overrides java.time.chrono.AbstractChronology.writeReplace.

Writes the Chronology using a dedicated serialized form.

Returns:Object

the instance of Ser, not null

Annotations
@Override
@Serial
Serial data
 out.writeByte(1);     // identifies a Chronology
 out.writeUTF(getId());
yearMonthToDayOfYearback to summary
private int yearMonthToDayOfYear(int prolepticYear, int month)

Returns the day of year for the requested HijrahYear and month.

Parameters
prolepticYear:int

the Hijrah year

month:int

the Hijrah month

Returns:int

the day of year for the start of the month of the year

yearToEpochMonthback to summary
private int yearToEpochMonth(int year)

Returns the epochMonth for the Hijrah Year.

Parameters
year:int

the HijrahYear

Returns:int

the epochMonth for the beginning of the year.

zonedDateTimeback to summary
public ChronoZonedDateTime<HijrahDate> zonedDateTime(TemporalAccessor temporal)

Overrides default java.time.chrono.Chronology.zonedDateTime.

Doc from java.time.chrono.Chronology.zonedDateTime.

Obtains a ChronoZonedDateTime in this chronology from another temporal object.

This obtains a zoned date-time in this chronology based on the specified temporal. A TemporalAccessor represents an arbitrary set of date and time information, which this factory converts to an instance of ChronoZonedDateTime.

The conversion will first obtain a ZoneId from the temporal object, falling back to a ZoneOffset if necessary. It will then try to obtain an Instant, falling back to a ChronoLocalDateTime if necessary. The result will be either the combination of ZoneId or ZoneOffset with Instant or ChronoLocalDateTime. Implementations are permitted to perform optimizations such as accessing those fields that are equivalent to the relevant objects. The result uses this chronology.

This method matches the signature of the functional interface TemporalQuery allowing it to be used as a query via method reference, aChronology::zonedDateTime.

Parameters
temporal:TemporalAccessor

the temporal object to convert, not null

Returns:ChronoZonedDateTime<HijrahDate>

the zoned date-time in this chronology, not null

Annotations
@Override
@SuppressWarnings:unchecked
zonedDateTimeback to summary
public ChronoZonedDateTime<HijrahDate> zonedDateTime(Instant instant, ZoneId zone)

Overrides default java.time.chrono.Chronology.zonedDateTime.

Doc from java.time.chrono.Chronology.zonedDateTime.

Obtains a ChronoZonedDateTime in this chronology from an Instant.

This obtains a zoned date-time with the same instant as that specified.

Parameters
instant:Instant

the instant to create the date-time from, not null

zone:ZoneId

the time-zone, not null

Returns:ChronoZonedDateTime<HijrahDate>

the zoned date-time, not null

Annotations
@Override
@SuppressWarnings:unchecked