Class BaseChronology
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AssembledChronology
BaseChronology is thread-safe and immutable, and all subclasses must be as well.
- Since:
- 1.0
- Author:
- Brian S O'Neill
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlong
add
(long instant, long duration, int scalar) Adds the duration to the instant, specifying the number of times to add.long
add
(ReadablePeriod period, long instant, int scalar) Adds the period to the instant, specifying the number of times to add.Get the centuries duration field for this chronology.Get the century of era field for this chronology.Get the hour of day (offset to 1-24) field for this chronology.Get the hour of am/pm (offset to 1-12) field for this chronology.Get the day of month field for this chronology.Get the day of week field for this chronology.Get the day of year field for this chronology.days()
Get the days duration field for this chronology.era()
Get the era field for this chronology.eras()
Get the eras duration field for this chronology.int[]
get
(ReadablePartial partial, long instant) Gets the values of a partial from an instant.int[]
get
(ReadablePeriod period, long duration) Gets the values of a period from an interval.int[]
get
(ReadablePeriod period, long startInstant, long endInstant) Gets the values of a period from an interval.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.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.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.Get the AM(0) PM(1) field for this chronology.halfdays()
Get the halfdays duration field for this chronology.Get the hour of day (0-23) field for this chronology.Get the hour of am/pm (0-11) field for this chronology.hours()
Get the hours duration field for this chronology.millis()
Get the millis duration field for this chronology.Get the millis of day field for this chronology.Get the millis of second field for this chronology.Get the minute of day field for this chronology.Get the minute of hour field for this chronology.minutes()
Get the minutes duration field for this chronology.Get the month of year field for this chronology.months()
Get the months duration field for this chronology.Get the second of day field for this chronology.Get the second of minute field for this chronology.seconds()
Get the seconds duration field for this chronology.long
set
(ReadablePartial partial, long instant) Sets the partial into the instant.abstract String
toString()
Gets a debugging toString.void
validate
(ReadablePartial partial, int[] values) Validates whether the fields stored in a partial instant are valid.Get the week of a week based year field for this chronology.weeks()
Get the weeks duration field for this chronology.weekyear()
Get the year of a week based year field for this chronology.Get the year of a week based year in a century field for this chronology.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.year()
Get the year field for this chronology.Get the year of century field for this chronology.Get the year of era field for this chronology.years()
Get the years duration field for this chronology.
-
Constructor Details
-
BaseChronology
protected BaseChronology()Restricted constructor.
-
-
Method Details
-
getZone
Returns the DateTimeZone that this Chronology operates in, or null if unspecified.- Specified by:
getZone
in classChronology
- Returns:
- 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.- Specified by:
withUTC
in classChronology
- Returns:
- a version of this chronology that ignores time zones
-
withZone
Returns an instance of this Chronology that operates in any time zone.- Specified by:
withZone
in classChronology
- Parameters:
zone
- to use, or default if null- Returns:
- a version of this chronology with a specific time zone
- See Also:
-
getDateTimeMillis
public long getDateTimeMillis(int year, int monthOfYear, int dayOfMonth, int millisOfDay) throws IllegalArgumentException 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.
- Specified by:
getDateTimeMillis
in classChronology
- 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 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.
- Specified by:
getDateTimeMillis
in classChronology
- 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 long getDateTimeMillis(long instant, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond) throws IllegalArgumentException 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.
- Specified by:
getDateTimeMillis
in classChronology
- 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 fields stored in a partial instant are valid.This implementation uses
DateTimeField.getMinimumValue(ReadablePartial, int[])
andDateTimeField.getMaximumValue(ReadablePartial, int[])
.- Specified by:
validate
in classChronology
- Parameters:
partial
- the partial instant to validatevalues
- the values to validate, not null unless the partial is empty- Throws:
IllegalArgumentException
- if the instant is invalid
-
get
Gets the values of a partial from an instant.- Specified by:
get
in classChronology
- Parameters:
partial
- the partial instant to useinstant
- the instant to query- Returns:
- the values of the partial extracted from the instant
-
set
Sets the partial into the instant.- Specified by:
set
in classChronology
- 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.- Specified by:
get
in classChronology
- 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.- Specified by:
get
in classChronology
- 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.- Specified by:
add
in classChronology
- 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 long add(long instant, long duration, int scalar) Adds the duration to the instant, specifying the number of times to add.- Specified by:
add
in classChronology
- 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.- Specified by:
millis
in classChronology
- Returns:
- DurationField or UnsupportedDurationField if unsupported
-
millisOfSecond
Get the millis of second field for this chronology.- Specified by:
millisOfSecond
in classChronology
- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
millisOfDay
Get the millis of day field for this chronology.- Specified by:
millisOfDay
in classChronology
- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
seconds
Get the seconds duration field for this chronology.- Specified by:
seconds
in classChronology
- Returns:
- DurationField or UnsupportedDurationField if unsupported
-
secondOfMinute
Get the second of minute field for this chronology.- Specified by:
secondOfMinute
in classChronology
- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
secondOfDay
Get the second of day field for this chronology.- Specified by:
secondOfDay
in classChronology
- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
minutes
Get the minutes duration field for this chronology.- Specified by:
minutes
in classChronology
- Returns:
- DurationField or UnsupportedDurationField if unsupported
-
minuteOfHour
Get the minute of hour field for this chronology.- Specified by:
minuteOfHour
in classChronology
- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
minuteOfDay
Get the minute of day field for this chronology.- Specified by:
minuteOfDay
in classChronology
- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
hours
Get the hours duration field for this chronology.- Specified by:
hours
in classChronology
- Returns:
- DurationField or UnsupportedDurationField if unsupported
-
hourOfDay
Get the hour of day (0-23) field for this chronology.- Specified by:
hourOfDay
in classChronology
- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
clockhourOfDay
Get the hour of day (offset to 1-24) field for this chronology.- Specified by:
clockhourOfDay
in classChronology
- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
halfdays
Get the halfdays duration field for this chronology.- Specified by:
halfdays
in classChronology
- Returns:
- DurationField or UnsupportedDurationField if unsupported
-
hourOfHalfday
Get the hour of am/pm (0-11) field for this chronology.- Specified by:
hourOfHalfday
in classChronology
- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
clockhourOfHalfday
Get the hour of am/pm (offset to 1-12) field for this chronology.- Specified by:
clockhourOfHalfday
in classChronology
- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
halfdayOfDay
Get the AM(0) PM(1) field for this chronology.- Specified by:
halfdayOfDay
in classChronology
- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
days
Get the days duration field for this chronology.- Specified by:
days
in classChronology
- 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.- Specified by:
dayOfWeek
in classChronology
- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
dayOfMonth
Get the day of month field for this chronology.- Specified by:
dayOfMonth
in classChronology
- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
dayOfYear
Get the day of year field for this chronology.- Specified by:
dayOfYear
in classChronology
- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
weeks
Get the weeks duration field for this chronology.- Specified by:
weeks
in classChronology
- Returns:
- DurationField or UnsupportedDurationField if unsupported
-
weekOfWeekyear
Get the week of a week based year field for this chronology.- Specified by:
weekOfWeekyear
in classChronology
- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
weekyears
Get the weekyears duration field for this chronology.- Specified by:
weekyears
in classChronology
- Returns:
- DurationField or UnsupportedDurationField if unsupported
-
weekyear
Get the year of a week based year field for this chronology.- Specified by:
weekyear
in classChronology
- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
weekyearOfCentury
Get the year of a week based year in a century field for this chronology.- Specified by:
weekyearOfCentury
in classChronology
- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
months
Get the months duration field for this chronology.- Specified by:
months
in classChronology
- Returns:
- DurationField or UnsupportedDurationField if unsupported
-
monthOfYear
Get the month of year field for this chronology.- Specified by:
monthOfYear
in classChronology
- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
years
Get the years duration field for this chronology.- Specified by:
years
in classChronology
- Returns:
- DurationField or UnsupportedDurationField if unsupported
-
year
Get the year field for this chronology.- Specified by:
year
in classChronology
- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
yearOfEra
Get the year of era field for this chronology.- Specified by:
yearOfEra
in classChronology
- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
yearOfCentury
Get the year of century field for this chronology.- Specified by:
yearOfCentury
in classChronology
- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
centuries
Get the centuries duration field for this chronology.- Specified by:
centuries
in classChronology
- Returns:
- DurationField or UnsupportedDurationField if unsupported
-
centuryOfEra
Get the century of era field for this chronology.- Specified by:
centuryOfEra
in classChronology
- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
eras
Get the eras duration field for this chronology.- Specified by:
eras
in classChronology
- Returns:
- DurationField or UnsupportedDurationField if unsupported
-
era
Get the era field for this chronology.- Specified by:
era
in classChronology
- Returns:
- DateTimeField or UnsupportedDateTimeField if unsupported
-
toString
Gets a debugging toString.- Specified by:
toString
in classChronology
- Returns:
- a debugging string
-