public final class IslamicChronology extends BasicChronology
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 & 29 - 15-based, used by Microsoft Years 2, 5, 7, 10, 13, 16, 18, 21, 24, 26 & 29 - 16-based, most commonly used Years 2, 5, 8, 10, 13, 16, 19, 21, 24, 27 & 29 - Indian Years 2, 5, 8, 11, 13, 16, 19, 21, 24, 27 & 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.
Modifier and Type | Class and Description |
---|---|
static class |
IslamicChronology.LeapYearPatternType
Opaque object describing a leap year pattern for the Islamic Chronology.
|
AssembledChronology.Fields
Modifier and Type | Field and Description |
---|---|
static int |
AH
Constant value for 'Anno Hegirae', equivalent
to the value returned for AD/CE.
|
private static java.util.concurrent.ConcurrentHashMap<DateTimeZone,IslamicChronology[]> |
cCache
Cache of zone to chronology arrays
|
private static int |
CYCLE
The length of the cycle of leap years.
|
private static DateTimeField |
ERA_FIELD
A singleton era field.
|
private IslamicChronology.LeapYearPatternType |
iLeapYears
The leap years to use.
|
private static IslamicChronology |
INSTANCE_UTC
Singleton instance of a UTC IslamicChronology
|
static IslamicChronology.LeapYearPatternType |
LEAP_YEAR_15_BASED
Leap year 15-based pattern.
|
static IslamicChronology.LeapYearPatternType |
LEAP_YEAR_16_BASED
Leap year 16-based pattern.
|
static IslamicChronology.LeapYearPatternType |
LEAP_YEAR_HABASH_AL_HASIB
Leap year Habash al-Hasib pattern.
|
static IslamicChronology.LeapYearPatternType |
LEAP_YEAR_INDIAN
Leap year Indian pattern.
|
private static int |
LONG_MONTH_LENGTH
The length of the long month.
|
private static int |
MAX_YEAR
The highest year that can be fully supported.
|
private static long |
MILLIS_PER_CYCLE
The millis of a 30 year cycle.
|
private static long |
MILLIS_PER_LONG_MONTH
The length of the long month in millis.
|
private static long |
MILLIS_PER_LONG_YEAR
The typical millis per year.
|
private static long |
MILLIS_PER_MONTH
The length of the long month in millis.
|
private static long |
MILLIS_PER_MONTH_PAIR
The length of the long month in millis.
|
private static long |
MILLIS_PER_SHORT_YEAR
The typical millis per year.
|
private static long |
MILLIS_PER_YEAR
The typical millis per year.
|
private static long |
MILLIS_YEAR_1
The millis of 0001-01-01.
|
private static int |
MIN_YEAR
The lowest year that can be fully supported.
|
private static int |
MONTH_PAIR_LENGTH
The days in a pair of months.
|
private static long |
serialVersionUID
Serialization lock
|
private static int |
SHORT_MONTH_LENGTH
The length of the short month.
|
Constructor and Description |
---|
IslamicChronology(Chronology base,
java.lang.Object param,
IslamicChronology.LeapYearPatternType leapYears)
Restricted constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
assemble(AssembledChronology.Fields fields)
Invoked by the constructor and after deserialization to allow subclasses
to define all of its supported fields.
|
(package private) long |
calculateFirstDayOfYearMillis(int year)
Gets the millisecond value of the first day of the year.
|
boolean |
equals(java.lang.Object obj)
Checks if this chronology instance equals another.
|
(package private) long |
getApproxMillisAtEpochDividedByTwo()
Returns a constant representing the approximate number of milliseconds
elapsed from year 0 of this chronology, divided by two.
|
(package private) long |
getAverageMillisPerMonth()
Gets an average value for the milliseconds per month.
|
(package private) long |
getAverageMillisPerYear()
Gets an average value for the milliseconds per year.
|
(package private) long |
getAverageMillisPerYearDividedByTwo()
Gets an average value for the milliseconds per year, divided by two.
|
(package private) int |
getDayOfMonth(long millis) |
(package private) int |
getDaysInMonthMax()
Gets the maximum number of days in any month.
|
(package private) int |
getDaysInMonthMax(int month)
Gets the maximum days in the specified month.
|
(package private) int |
getDaysInYear(int year)
Get the number of days in the year.
|
(package private) int |
getDaysInYearMax()
Get the number of days in the year.
|
(package private) int |
getDaysInYearMonth(int year,
int month)
Gets the number of days in the specified month and year.
|
static IslamicChronology |
getInstance()
Gets an instance of the IslamicChronology in the default time zone.
|
static IslamicChronology |
getInstance(DateTimeZone zone)
Gets an instance of the IslamicChronology in the given time zone.
|
static IslamicChronology |
getInstance(DateTimeZone zone,
IslamicChronology.LeapYearPatternType leapYears)
Gets an instance of the IslamicChronology in the given time zone.
|
static IslamicChronology |
getInstanceUTC()
Gets an instance of the IslamicChronology.
|
IslamicChronology.LeapYearPatternType |
getLeapYearPatternType()
Gets the leap year pattern type.
|
(package private) int |
getMaxYear()
Gets the maximum supported year.
|
(package private) int |
getMinYear()
Gets the minimum supported year.
|
(package private) int |
getMonthOfYear(long millis,
int year) |
(package private) long |
getTotalMillisByYearMonth(int year,
int month)
Gets the total number of millis elapsed in this year at the start
of the specified month, such as zero for month 1.
|
(package private) int |
getYear(long instant) |
(package private) long |
getYearDifference(long minuendInstant,
long subtrahendInstant)
Gets the difference between the two instants in years.
|
int |
hashCode()
A suitable hash code for the chronology.
|
(package private) boolean |
isLeapYear(int year)
Is the specified year a leap year?
|
private java.lang.Object |
readResolve()
Serialization singleton.
|
(package private) long |
setYear(long instant,
int year)
Sets the year from an instant and year.
|
Chronology |
withUTC()
Gets the Chronology in the UTC time zone.
|
Chronology |
withZone(DateTimeZone zone)
Gets the Chronology in a specific time zone.
|
getDateMidnightMillis, getDateTimeMillis, getDateTimeMillis, getDayOfMonth, getDayOfMonth, getDayOfWeek, getDayOfYear, getDayOfYear, getDaysInMonthMax, getDaysInMonthMaxForSet, getFirstWeekOfYearMillis, getMaxMonth, getMaxMonth, getMillisOfDay, getMinimumDaysInFirstWeek, getMonthOfYear, getWeekOfWeekyear, getWeekOfWeekyear, getWeeksInYear, getWeekyear, getYearMillis, getYearMonthDayMillis, getYearMonthMillis, getZone, isLeapDay, toString
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
private static final long serialVersionUID
public static final int AH
private static final DateTimeField ERA_FIELD
public static final IslamicChronology.LeapYearPatternType LEAP_YEAR_15_BASED
public static final IslamicChronology.LeapYearPatternType LEAP_YEAR_16_BASED
public static final IslamicChronology.LeapYearPatternType LEAP_YEAR_INDIAN
public static final IslamicChronology.LeapYearPatternType LEAP_YEAR_HABASH_AL_HASIB
private static final int MIN_YEAR
private static final int MAX_YEAR
private static final int MONTH_PAIR_LENGTH
private static final int LONG_MONTH_LENGTH
private static final int SHORT_MONTH_LENGTH
private static final long MILLIS_PER_MONTH_PAIR
private static final long MILLIS_PER_MONTH
private static final long MILLIS_PER_LONG_MONTH
private static final long MILLIS_PER_YEAR
private static final long MILLIS_PER_SHORT_YEAR
private static final long MILLIS_PER_LONG_YEAR
private static final long MILLIS_YEAR_1
private static final int CYCLE
private static final long MILLIS_PER_CYCLE
private static final java.util.concurrent.ConcurrentHashMap<DateTimeZone,IslamicChronology[]> cCache
private static final IslamicChronology INSTANCE_UTC
private final IslamicChronology.LeapYearPatternType iLeapYears
IslamicChronology(Chronology base, java.lang.Object param, IslamicChronology.LeapYearPatternType leapYears)
public static IslamicChronology getInstanceUTC()
public static IslamicChronology getInstance()
public static IslamicChronology getInstance(DateTimeZone zone)
zone
- the time zone to get the chronology in, null is defaultpublic static IslamicChronology getInstance(DateTimeZone zone, IslamicChronology.LeapYearPatternType leapYears)
zone
- the time zone to get the chronology in, null is defaultleapYears
- the type defining the leap year patternprivate java.lang.Object readResolve()
public IslamicChronology.LeapYearPatternType getLeapYearPatternType()
public Chronology withUTC()
withUTC
in class BaseChronology
public Chronology withZone(DateTimeZone zone)
withZone
in class BaseChronology
zone
- the zone to get the chronology in, null is defaultZonedChronology
public boolean equals(java.lang.Object obj)
equals
in class BasicChronology
obj
- the object to compare topublic int hashCode()
hashCode
in class BasicChronology
int getYear(long instant)
getYear
in class BasicChronology
instant
- millis from 1970-01-01T00:00:00Zlong setYear(long instant, int year)
BasicChronology
setYear
in class BasicChronology
instant
- millis from 1970-01-01T00:00:00Zyear
- the year to setlong getYearDifference(long minuendInstant, long subtrahendInstant)
BasicChronology
getYearDifference
in class BasicChronology
minuendInstant
- the first instantsubtrahendInstant
- the second instantlong getTotalMillisByYearMonth(int year, int month)
BasicChronology
getTotalMillisByYearMonth
in class BasicChronology
year
- the yearmonth
- the monthint getDayOfMonth(long millis)
getDayOfMonth
in class BasicChronology
millis
- from 1970-01-01T00:00:00Zboolean isLeapYear(int year)
BasicChronology
isLeapYear
in class BasicChronology
year
- the year to testint getDaysInYearMax()
BasicChronology
getDaysInYearMax
in class BasicChronology
int getDaysInYear(int year)
BasicChronology
getDaysInYear
in class BasicChronology
year
- the year to useint getDaysInYearMonth(int year, int month)
BasicChronology
getDaysInYearMonth
in class BasicChronology
year
- the yearmonth
- the monthint getDaysInMonthMax()
BasicChronology
getDaysInMonthMax
in class BasicChronology
int getDaysInMonthMax(int month)
BasicChronology
getDaysInMonthMax
in class BasicChronology
month
- the monthint getMonthOfYear(long millis, int year)
getMonthOfYear
in class BasicChronology
millis
- from 1970-01-01T00:00:00Zyear
- precalculated year of millislong getAverageMillisPerYear()
BasicChronology
getAverageMillisPerYear
in class BasicChronology
long getAverageMillisPerYearDividedByTwo()
BasicChronology
getAverageMillisPerYearDividedByTwo
in class BasicChronology
long getAverageMillisPerMonth()
BasicChronology
getAverageMillisPerMonth
in class BasicChronology
long calculateFirstDayOfYearMillis(int year)
BasicChronology
calculateFirstDayOfYearMillis
in class BasicChronology
int getMinYear()
BasicChronology
getMinYear
in class BasicChronology
int getMaxYear()
BasicChronology
getMaxYear
in class BasicChronology
long getApproxMillisAtEpochDividedByTwo()
BasicChronology
(yearAtEpoch * averageMillisPerYear + millisOfYearAtEpoch) / 2where epoch is 1970-01-01 (Gregorian).
getApproxMillisAtEpochDividedByTwo
in class BasicChronology
protected void assemble(AssembledChronology.Fields fields)
AssembledChronology
assemble
in class BasicChronology
fields
- container of fields