Class Chronology
- Direct Known Subclasses:
BaseChronology
Various chronologies are supported by subclasses including ISO and GregorianJulian. To construct a Chronology you should use the factory methods on the chronology subclass in the chrono package.
For example, to obtain the current time in the coptic calendar system:
DateTime dt = new DateTime(CopticChronology.getInstance());
The provided chronology implementations are:
- ISO - The de facto world calendar system, based on the ISO-8601 standard
- GJ - Historically accurate calendar with Julian followed by Gregorian
- Gregorian - The Gregorian calendar system used for all time (proleptic)
- Julian - The Julian calendar system used for all time (proleptic)
- Buddhist - The Buddhist calendar system which is an offset in years from GJ
- Coptic - The Coptic calendar system which defines 30 day months
- Ethiopic - The Ethiopic calendar system which defines 30 day months
- Islamic - The Islamic, or Hijri, lunar calendar system
This class defines a number of fields with names from the ISO8601 standard. It does not 'strongly' define these fields however, thus implementations are free to interpret the field names as they wish. For example, a week could be defined as 10 days and a month as 40 days in a special WeirdChronology implementation. Clearly the GJ and ISO implementations provided use the field names as you would expect.
- Since:
- 1.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract long
add
(long instant, long duration, int scalar) Adds the duration to the instant, specifying the number of times to add.abstract long
add
(ReadablePeriod period, long instant, int scalar) Adds the period to the instant, specifying the number of times to add.abstract DurationField
Get the centuries duration field for this chronology.abstract DateTimeField
Get the century of era field for this chronology.abstract DateTimeField
Get the hour of day (offset to 1-24) field for this chronology.abstract DateTimeField
Get the hour of am/pm (offset to 1-12) field for this chronology.abstract DateTimeField
Get the day of month field for this chronology.abstract DateTimeField
Get the day of week field for this chronology.abstract DateTimeField
Get the day of year field for this chronology.abstract DurationField
days()
Get the days duration field for this chronology.abstract DateTimeField
era()
Get the era field for this chronology.abstract DurationField
eras()
Get the eras duration field for this chronology.abstract int[]
get
(ReadablePartial partial, long instant) Gets the values of a partial from an instant.abstract int[]
get
(ReadablePeriod period, long duration) Gets the values of a period from an interval.abstract int[]
get
(ReadablePeriod period, long startInstant, long endInstant) Gets the values of a period from an interval.abstract long
getDateTimeMillis
(int year, int monthOfYear, int dayOfMonth, int millisOfDay) Returns a datetime millisecond instant, formed from the given year, month, day, and millisecond values.abstract long
getDateTimeMillis
(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.abstract long
getDateTimeMillis
(long instant, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond) Returns a datetime millisecond instant, from from the given instant, hour, minute, second, and millisecond values.abstract DateTimeZone
getZone()
Returns the DateTimeZone that this Chronology operates in, or null if unspecified.abstract DateTimeField
Get the AM(0) PM(1) field for this chronology.abstract DurationField
halfdays()
Get the halfdays duration field for this chronology.abstract DateTimeField
Get the hour of day (0-23) field for this chronology.abstract DateTimeField
Get the hour of am/pm (0-11) field for this chronology.abstract DurationField
hours()
Get the hours duration field for this chronology.abstract DurationField
millis()
Get the millis duration field for this chronology.abstract DateTimeField
Get the millis of day field for this chronology.abstract DateTimeField
Get the millis of second field for this chronology.abstract DateTimeField
Get the minute of day field for this chronology.abstract DateTimeField
Get the minute of hour field for this chronology.abstract DurationField
minutes()
Get the minutes duration field for this chronology.abstract DateTimeField
Get the month of year field for this chronology.abstract DurationField
months()
Get the months duration field for this chronology.abstract DateTimeField
Get the second of day field for this chronology.abstract DateTimeField
Get the second of minute field for this chronology.abstract DurationField
seconds()
Get the seconds duration field for this chronology.abstract long
set
(ReadablePartial partial, long instant) Sets the partial into the instant.abstract String
toString()
Gets a debugging toString.abstract void
validate
(ReadablePartial partial, int[] values) Validates whether the values are valid for the fields of a partial instant.abstract DateTimeField
Get the week of a week based year field for this chronology.abstract DurationField
weeks()
Get the weeks duration field for this chronology.abstract DateTimeField
weekyear()
Get the year of a week based year field for this chronology.abstract DateTimeField
Get the year of a week based year in a century field for this chronology.abstract DurationField
Get the weekyears duration field for this chronology.abstract Chronology
withUTC()
Returns an instance of this Chronology that operates in the UTC time zone.abstract Chronology
withZone
(DateTimeZone zone) Returns an instance of this Chronology that operates in any time zone.abstract DateTimeField
year()
Get the year field for this chronology.abstract DateTimeField
Get the year of century field for this chronology.abstract DateTimeField
Get the year of era field for this chronology.abstract DurationField
years()
Get the years duration field for this chronology.
-
Constructor Details
-
Chronology
public Chronology()
-
-
Method Details
-
getZone
Returns the DateTimeZone that this Chronology operates in, or null if unspecified.- Returns:
- the DateTimeZone, null if unspecified
-
withUTC
Returns an instance of this Chronology that operates in the UTC time zone. Chronologies that do not operate in a time zone or are already UTC must return themselves.- Returns:
- a version of this chronology that ignores time zones
-
withZone
Returns an instance of this Chronology that operates in any time zone.- Parameters:
zone
- to use, or default if null- Returns:
- a version of this chronology with a specific time zone
- See Also:
-
getDateTimeMillis
public abstract long getDateTimeMillis(int year, int monthOfYear, int dayOfMonth, int millisOfDay) Returns 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.
- 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 abstract long getDateTimeMillis(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. 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.
- 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
-
getDateTimeMillis
public abstract long getDateTimeMillis(long instant, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond) Returns a datetime millisecond instant, from from the given instant, 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.
- Parameters:
instant
- instant to start fromhourOfDay
- 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
-
validate
Validates whether the values are valid for the fields of a partial instant.- Parameters:
partial
- the partial instant to validatevalues
- the values to validate, not null, match fields in partial- Throws:
IllegalArgumentException
- if the instant is invalid
-
get
Gets the values of a partial from an instant.- Parameters:
partial
- the partial instant to useinstant
- the instant to query- Returns:
- the values of this partial extracted from the instant
-
set
Sets the partial into the instant.- Parameters:
partial
- the partial instant to useinstant
- the instant to update- Returns:
- the updated instant
-
get
Gets the values of a period from an interval.- Parameters:
period
- the period instant to usestartInstant
- the start instant of an interval to queryendInstant
- the start instant of an interval to query- Returns:
- the values of the period extracted from the interval
-
get
Gets the values of a period from an interval.- Parameters:
period
- the period instant to useduration
- the duration to query- Returns:
- the values of the period extracted from the duration
-
add
Adds the period to the instant, specifying the number of times to add.- Parameters:
period
- the period to add, null means add nothinginstant
- the instant to add toscalar
- the number of times to add- Returns:
- the updated instant
-
add
public abstract long add(long instant, long duration, int scalar) Adds the duration to the instant, specifying the number of times to add.- Parameters:
instant
- the instant to add toduration
- the duration to addscalar
- the number of times to add- Returns:
- the updated instant
-
millis
Get the millis duration field for this chronology.- Returns:
- DurationField or UnsupportedDurationField if unsupported
-
millisOfSecond
Get the millis of second field for this chronology.- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
millisOfDay
Get the millis of day field for this chronology.- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
seconds
Get the seconds duration field for this chronology.- Returns:
- DurationField or UnsupportedDurationField if unsupported
-
secondOfMinute
Get the second of minute field for this chronology.- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
secondOfDay
Get the second of day field for this chronology.- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
minutes
Get the minutes duration field for this chronology.- Returns:
- DurationField or UnsupportedDurationField if unsupported
-
minuteOfHour
Get the minute of hour field for this chronology.- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
minuteOfDay
Get the minute of day field for this chronology.- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
hours
Get the hours duration field for this chronology.- Returns:
- DurationField or UnsupportedDurationField if unsupported
-
hourOfDay
Get the hour of day (0-23) field for this chronology.- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
clockhourOfDay
Get the hour of day (offset to 1-24) field for this chronology.- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
halfdays
Get the halfdays duration field for this chronology.- Returns:
- DurationField or UnsupportedDurationField if unsupported
-
hourOfHalfday
Get the hour of am/pm (0-11) field for this chronology.- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
clockhourOfHalfday
Get the hour of am/pm (offset to 1-12) field for this chronology.- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
halfdayOfDay
Get the AM(0) PM(1) field for this chronology.- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
days
Get the days duration field for this chronology.- Returns:
- DurationField or UnsupportedDurationField if unsupported
-
dayOfWeek
Get the day of week field for this chronology.DayOfWeek values are defined in
DateTimeConstants
. They use the ISO definitions, where 1 is Monday and 7 is Sunday.- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
dayOfMonth
Get the day of month field for this chronology.- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
dayOfYear
Get the day of year field for this chronology.- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
weeks
Get the weeks duration field for this chronology.- Returns:
- DurationField or UnsupportedDurationField if unsupported
-
weekOfWeekyear
Get the week of a week based year field for this chronology.- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
weekyears
Get the weekyears duration field for this chronology.- Returns:
- DurationField or UnsupportedDurationField if unsupported
-
weekyear
Get the year of a week based year field for this chronology.- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
weekyearOfCentury
Get the year of a week based year in a century field for this chronology.- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
months
Get the months duration field for this chronology.- Returns:
- DurationField or UnsupportedDurationField if unsupported
-
monthOfYear
Get the month of year field for this chronology.- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
years
Get the years duration field for this chronology.- Returns:
- DurationField or UnsupportedDurationField if unsupported
-
year
Get the year field for this chronology.- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
yearOfEra
Get the year of era field for this chronology.- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
yearOfCentury
Get the year of century field for this chronology.- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
centuries
Get the centuries duration field for this chronology.- Returns:
- DurationField or UnsupportedDurationField if unsupported
-
centuryOfEra
Get the century of era field for this chronology.- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
eras
Get the eras duration field for this chronology.- Returns:
- DurationField or UnsupportedDurationField if unsupported
-
era
Get the era field for this chronology.- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
toString
Gets a debugging toString.
-