Class IslamicChronology
- All Implemented Interfaces:
Serializable
This calendar is a lunar calendar with a shorter year than ISO. Year 1 in the Islamic calendar began on July 16, 622 CE (Julian), thus Islamic years do not begin at the same time as Julian years. This chronology is not proleptic, as it does not allow dates before the first Islamic year.
There are two basic forms of the Islamic calendar, the tabular and the observed. The observed form cannot easily be used by computers as it relies on human observation of the new moon. The tabular calendar, implemented here, is an arithmetical approximation of the observed form that follows relatively simple rules.
The tabular form of the calendar defines 12 months of alternately 30 and 29 days. The last month is extended to 30 days in a leap year. Leap years occur according to a 30 year cycle. There are four recognised patterns of leap years in the 30 year cycle:
Years 2, 5, 7, 10, 13, 15, 18, 21, 24, 26 invalid input: '&' 29 - 15-based, used by Microsoft Years 2, 5, 7, 10, 13, 16, 18, 21, 24, 26 invalid input: '&' 29 - 16-based, most commonly used Years 2, 5, 8, 10, 13, 16, 19, 21, 24, 27 invalid input: '&' 29 - Indian Years 2, 5, 8, 11, 13, 16, 19, 21, 24, 27 invalid input: '&' 30 - Habash al-HasibYou can select which pattern to use via the factory methods, or use the default (16-based).
This implementation defines a day as midnight to midnight exactly as per the ISO chronology. This correct start of day is at sunset on the previous day, however this cannot readily be modelled and has been ignored.
IslamicChronology is thread-safe and immutable.
- Since:
- 1.2
- Author:
- Stephen Colebourne
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classOpaque object describing a leap year pattern for the Islamic Chronology.Nested classes/interfaces inherited from class org.joda.time.chrono.AssembledChronology
AssembledChronology.Fields -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intConstant value for 'Anno Hegirae', equivalent to the value returned for AD/CE.static final IslamicChronology.LeapYearPatternTypeLeap year 15-based pattern.static final IslamicChronology.LeapYearPatternTypeLeap year 16-based pattern.static final IslamicChronology.LeapYearPatternTypeLeap year Habash al-Hasib pattern.static final IslamicChronology.LeapYearPatternTypeLeap year Indian pattern. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidassemble(AssembledChronology.Fields fields) Invoked by the constructor and after deserialization to allow subclasses to define all of its supported fields.booleanChecks if this chronology instance equals another.longgetDateTimeMillis(int year, int monthOfYear, int dayOfMonth, int millisOfDay) Returns a datetime millisecond instant, formed from the given year, month, day, and millisecond values.longgetDateTimeMillis(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond) Returns a datetime millisecond instant, formed from the given year, month, day, hour, minute, second, and millisecond values.static IslamicChronologyGets an instance of the IslamicChronology in the default time zone.static IslamicChronologygetInstance(DateTimeZone zone) Gets an instance of the IslamicChronology in the given time zone.static IslamicChronologygetInstance(DateTimeZone zone, IslamicChronology.LeapYearPatternType leapYears) Gets an instance of the IslamicChronology in the given time zone.static IslamicChronologyGets an instance of the IslamicChronology.Gets the leap year pattern type.intgetZone()Returns the DateTimeZone that this Chronology operates in, or null if unspecified.inthashCode()A suitable hash code for the chronology.toString()Gets a debugging toString.withUTC()Gets the Chronology in the UTC time zone.withZone(DateTimeZone zone) Gets the Chronology in a specific time zone.Methods inherited from class org.joda.time.chrono.AssembledChronology
centuries, centuryOfEra, clockhourOfDay, clockhourOfHalfday, dayOfMonth, dayOfWeek, dayOfYear, days, era, eras, getBase, getDateTimeMillis, getParam, halfdayOfDay, halfdays, hourOfDay, hourOfHalfday, hours, millis, millisOfDay, millisOfSecond, minuteOfDay, minuteOfHour, minutes, monthOfYear, months, secondOfDay, secondOfMinute, seconds, weekOfWeekyear, weeks, weekyear, weekyearOfCentury, weekyears, year, yearOfCentury, yearOfEra, years
-
Field Details
-
AH
public static final int AHConstant value for 'Anno Hegirae', equivalent to the value returned for AD/CE.- See Also:
-
LEAP_YEAR_15_BASED
Leap year 15-based pattern. -
LEAP_YEAR_16_BASED
Leap year 16-based pattern. -
LEAP_YEAR_INDIAN
Leap year Indian pattern. -
LEAP_YEAR_HABASH_AL_HASIB
Leap year Habash al-Hasib pattern.
-
-
Method Details
-
getInstanceUTC
Gets an instance of the IslamicChronology. The time zone of the returned instance is UTC.- Returns:
- a singleton UTC instance of the chronology
-
getInstance
Gets an instance of the IslamicChronology in the default time zone.- Returns:
- a chronology in the default time zone
-
getInstance
Gets an instance of the IslamicChronology in the given time zone.- Parameters:
zone- the time zone to get the chronology in, null is default- Returns:
- a chronology in the specified time zone
-
getInstance
public static IslamicChronology getInstance(DateTimeZone zone, IslamicChronology.LeapYearPatternType leapYears) Gets an instance of the IslamicChronology in the given time zone.- Parameters:
zone- the time zone to get the chronology in, null is defaultleapYears- the type defining the leap year pattern- Returns:
- a chronology in the specified time zone
-
getLeapYearPatternType
Gets the leap year pattern type.- Returns:
- the pattern type
-
withUTC
Gets the Chronology in the UTC time zone.- Specified by:
withUTCin classBaseChronology- Returns:
- the chronology in UTC
-
withZone
Gets the Chronology in a specific time zone.- Specified by:
withZonein classBaseChronology- Parameters:
zone- the zone to get the chronology in, null is default- Returns:
- the chronology
- See Also:
-
equals
Checks if this chronology instance equals another.- Parameters:
obj- the object to compare to- Returns:
- true if equal
- Since:
- 2.3
-
hashCode
public int hashCode()A suitable hash code for the chronology.- Returns:
- the hash code
- Since:
- 1.6
-
assemble
Description copied from class:AssembledChronologyInvoked by the constructor and after deserialization to allow subclasses to define all of its supported fields. All unset fields default to unsupported instances.- Parameters:
fields- container of fields
-
getZone
Description copied from class:BaseChronologyReturns the DateTimeZone that this Chronology operates in, or null if unspecified.- Overrides:
getZonein classAssembledChronology- Returns:
- DateTimeZone null if unspecified
-
getDateTimeMillis
public long getDateTimeMillis(int year, int monthOfYear, int dayOfMonth, int millisOfDay) throws IllegalArgumentException Description copied from class:BaseChronologyReturns a datetime millisecond instant, formed from the given year, month, day, and millisecond values. The set of given values must refer to a valid datetime, or else an IllegalArgumentException is thrown.The default implementation calls upon separate DateTimeFields to determine the result. Subclasses are encouraged to provide a more efficient implementation.
- Overrides:
getDateTimeMillisin classAssembledChronology- Parameters:
year- year to usemonthOfYear- month to usedayOfMonth- day of month to usemillisOfDay- millisecond to use- Returns:
- millisecond instant from 1970-01-01T00:00:00Z
- Throws:
IllegalArgumentException- if the values are invalid
-
getDateTimeMillis
public long getDateTimeMillis(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond) throws IllegalArgumentException Description copied from class:BaseChronologyReturns a datetime millisecond instant, formed from the given year, month, day, hour, minute, second, and millisecond values. The set of given values must refer to a valid datetime, or else an IllegalArgumentException is thrown.The default implementation calls upon separate DateTimeFields to determine the result. Subclasses are encouraged to provide a more efficient implementation.
- Overrides:
getDateTimeMillisin classAssembledChronology- Parameters:
year- year to usemonthOfYear- month to usedayOfMonth- day of month to usehourOfDay- hour to useminuteOfHour- minute to usesecondOfMinute- second to usemillisOfSecond- millisecond to use- Returns:
- millisecond instant from 1970-01-01T00:00:00Z
- Throws:
IllegalArgumentException- if the values are invalid
-
getMinimumDaysInFirstWeek
public int getMinimumDaysInFirstWeek() -
toString
Gets a debugging toString.- Specified by:
toStringin classBaseChronology- Returns:
- a debugging string
-