Class ISOChronology
- All Implemented Interfaces:
Serializable, Calendrical
ISOChronology follows the rules of the Gregorian calendar for all time. Thus, dates is the past, and particularly before 1583, may not correspond to historical documents.
ISOChronology is immutable and thread-safe.
- Author:
- Michael Nascimento Santos, Stephen Colebourne
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ISOChronologyThe singleton instance ofISOChronology.static final intConstant for the maximum week-based-year.static final intConstant for the minimum week-based-year. -
Method Summary
Modifier and TypeMethodDescriptionstatic DateTimeFieldRule<AmPmOfDay> Gets the rule for the AM/PM of day field.static DateTimeFieldRule<Integer> Gets the rule for the clock hour of AM/PM field from 1 to 12.static DateTimeFieldRule<Integer> Gets the rule for the clock hour of AM/PM field from 1 to 24.static DateTimeFieldRule<Integer> Gets the rule for the day-of-month field in the ISO chronology.static DateTimeFieldRule<DayOfWeek> Gets the rule for the day-of-week field.static DateTimeFieldRule<Integer> Gets the rule for the day-of-year field in the ISO chronology.static CalendricalRule<Long> Gets the rule for the epoch-days field.getName()Gets the name of the chronology.static DateTimeFieldRule<Integer> Gets the rule for the hour of AM/PM field from 0 to 11.static DateTimeFieldRule<Integer> Gets the rule for the hour-of-day field.static booleanisLeapYear(int year) Checks if the specified year is a leap year according to the ISO calendar system rules.static DateTimeFieldRule<Integer> Gets the rule for the milli-of-day field.static DateTimeFieldRule<Integer> Gets the rule for the milli-of-second field.static DateTimeFieldRule<Integer> Gets the rule for the minute-of-hour field.static DateTimeFieldRule<Integer> Gets the rule for the month-of-quarter field in the ISO chronology.static DateTimeFieldRule<MonthOfYear> Gets the rule for the month-of-year field in the ISO chronology.static CalendricalRule<Long> Gets the rule for the nano-of-day field.static DateTimeFieldRule<Integer> Gets the rule for the nano-of-second field.static PeriodUnitGets the period unit for twelve hours, as used by AM/PM.static PeriodUnitGets the period unit for twenty-four hours, that is often treated as a day.static PeriodUnitGets the period unit for centuries of 100 years.static PeriodUnitGets the period unit for days.static PeriodUnitGets the period unit for decades of 10 years.static PeriodUnitGets the period unit for eras.static PeriodUnitGets the period unit for hours of 60 minutes.static PeriodUnitGets the period unit for microseconds.static PeriodUnitGets the period unit for millennia of 1000 years.static PeriodUnitGets the period unit for milliseconds.static PeriodUnitGets the period unit for minutes of 60 seconds.static PeriodUnitGets the period unit for months.static PeriodUnitGets the period unit for nanoseconds.static PeriodUnitGets the period unit for quarters of 3 months.static PeriodUnitGets the period unit for seconds.static PeriodUnitGets the period unit for week-based-years.static PeriodUnitGets the period unit for weeks of 7 days.static PeriodUnitGets the period unit for years of 12 months.static DateTimeFieldRule<QuarterOfYear> Gets the rule for the quarter-of-year field in the ISO chronology.static DateTimeFieldRule<Integer> Gets the rule for the second-of-day field.static DateTimeFieldRule<Integer> Gets the rule for the second-of-minute field.static DateTimeFieldRule<Integer> Gets the rule for the week-based-year field in the ISO chronology.static DateTimeFieldRule<Integer> Gets the rule for the week-of-month field in the ISO chronology.static DateTimeFieldRule<Integer> Gets the rule for the week-of-week-based-year field in the ISO chronology.static DateTimeFieldRule<Integer> Gets the rule for the week-of-year field in the ISO chronology.static DateTimeFieldRule<Integer> yearRule()Gets the rule for the year field in the ISO chronology.Methods inherited from class Chronology
get, rule, toString
-
Field Details
-
INSTANCE
The singleton instance ofISOChronology. -
MIN_WEEK_BASED_YEAR
public static final int MIN_WEEK_BASED_YEARConstant for the minimum week-based-year.- See Also:
-
MAX_WEEK_BASED_YEAR
public static final int MAX_WEEK_BASED_YEARConstant for the maximum week-based-year.- See Also:
-
-
Method Details
-
isLeapYear
public static boolean isLeapYear(int year) Checks if the specified year is a leap year according to the ISO calendar system rules.The ISO calendar system applies the current rules for leap years across the whole time-line. In general, a year is a leap year if it is divisible by four without remainder. However, years divisible by 100, are not leap years, with the exception of years divisible by 400 which are.
For example, 1904 is a leap year it is divisible by 4. 1900 was not a leap year as it is divisible by 100, however 2000 was a leap year as it is divisible by 400.
The calculation is proleptic - applying the same rules into the far future and far past. This is historically inaccurate, but is correct for the ISO8601 standard.
- Parameters:
year- the year to check, not validated for range- Returns:
- true if the year is a leap year
-
getName
Gets the name of the chronology.- Specified by:
getNamein classChronology- Returns:
- the name of the chronology, never null
-
yearRule
Gets the rule for the year field in the ISO chronology.This field counts years using the modern civil calendar system as defined by ISO-8601. There is no historical cutover (as found in historical dates such as from the Julian to Gregorian calendar).
The implication of this is that historical dates will not be accurate. All work requiring accurate historical dates must use the appropriate chronology that defines the Gregorian cutover.
A further implication of the ISO-8601 rules is that the year zero exists. This roughly equates to 1 BC/BCE, however the alignment is not exact as explained above.
- Returns:
- the rule for the year field, never null
-
monthOfYearRule
Gets the rule for the month-of-year field in the ISO chronology.This field counts months sequentially from the start of the year. The values follow the ISO-8601 standard and normal human interactions. These define January as value 1 to December as value 12.
The enum
MonthOfYearshould be used wherever possible in applications when referring to the day of the week to avoid hard-coding the values.- Returns:
- the rule for the month-of-year field, never null
-
dayOfMonthRule
Gets the rule for the day-of-month field in the ISO chronology.This field counts days sequentially from the start of the month. The first day of the month is 1 and the last is 28, 29, 30 or 31 depending on the month and whether it is a leap year.
- Returns:
- the rule for the day-of-month field, never null
-
dayOfYearRule
Gets the rule for the day-of-year field in the ISO chronology.This field counts days sequentially from the start of the year. The first day of the year is 1 and the last is 365, or 366 in a leap year.
- Returns:
- the rule for the day-of-year field, never null
-
weekBasedYearRule
Gets the rule for the week-based-year field in the ISO chronology.This field is the year that results from calculating weeks with the ISO-8601 algorithm. See
week of week-based-yearfor details.The week-based-year will either be 52 or 53 weeks long, depending on the result of the algorithm for a particular date.
- Returns:
- the rule for the week-based-year field, never null
-
weekOfWeekBasedYearRule
Gets the rule for the week-of-week-based-year field in the ISO chronology.This field counts weeks using the ISO-8601 algorithm. The first week of the year is the week which has at least 4 days in the year using a Monday to Sunday week definition. Thus it is possible for the first week to start on any day from the 29th December in the previous year to the 4th January in the new year. The year which is aligned with this field is known as the
week-based-year.- Returns:
- the rule for the week-of-week-based-year field, never null
-
dayOfWeekRule
Gets the rule for the day-of-week field.This field uses the ISO-8601 values for the day-of-week. These define Monday as value 1 to Sunday as value 7.
The enum
DayOfWeekshould be used wherever possible in applications when referring to the day of the week value to avoid needing to remember the values from 1 to 7.- Returns:
- the rule for the day-of-week field, never null
-
weekOfYearRule
Gets the rule for the week-of-year field in the ISO chronology.This field counts weeks in groups of seven days starting from the first of January. The 1st to the 7th of January is always week 1 while the 8th to the 14th is always week 2.
- Returns:
- the rule for the week-of-year field, never null
-
quarterOfYearRule
Gets the rule for the quarter-of-year field in the ISO chronology.This field counts quarters sequentially from the start of the year. The first quarter of the year is 1 and the last is 4. Each quarter lasts exactly three months.
- Returns:
- the rule for the quarter-of-year field, never null
-
monthOfQuarterRule
Gets the rule for the month-of-quarter field in the ISO chronology.This field counts months sequentially from the start of the quarter. The first month of the quarter is 1 and the last is 3. Each quarter lasts exactly three months.
- Returns:
- the rule for the month-of-quarter field, never null
-
weekOfMonthRule
Gets the rule for the week-of-month field in the ISO chronology.This field counts weeks in groups of seven days starting from the first day of the month. The 1st to the 7th of a month is always week 1 while the 8th to the 14th is always week 2 and so on.
This field can be used to create concepts such as 'the second Saturday' of a month. To achieve this, setup a
DateTimeFieldsinstance using this rule and theday-of-weekrule.- Returns:
- the rule for the week-of-month field, never null
-
hourOfDayRule
Gets the rule for the hour-of-day field.This field counts hours sequentially from the start of the day. The values run from 0 to 23.
- Returns:
- the rule for the hour-of-day field, never null
-
minuteOfHourRule
Gets the rule for the minute-of-hour field.This field counts minutes sequentially from the start of the hour. The values run from 0 to 59.
- Returns:
- the rule for the minute-of-hour field, never null
-
secondOfMinuteRule
Gets the rule for the second-of-minute field.This field counts seconds sequentially from the start of the minute. The values run from 0 to 59.
- Returns:
- the rule for the second-of-minute field, never null
-
nanoOfSecondRule
Gets the rule for the nano-of-second field.This field counts nanoseconds sequentially from the start of the second. The values run from 0 to 999,999,999.
- Returns:
- the rule for the nano-of-second field, never null
-
secondOfDayRule
Gets the rule for the second-of-day field.This field counts seconds sequentially from the start of the day. The values run from 0 to 86399.
- Returns:
- the rule for the second-of-day field, never null
-
milliOfDayRule
Gets the rule for the milli-of-day field.This field counts milliseconds sequentially from the start of the day. The values run from 0 to 86,399,999.
- Returns:
- the rule for the milli-of-day field, never null
-
milliOfSecondRule
Gets the rule for the milli-of-second field.This field counts milliseconds sequentially from the start of the second. The values run from 0 to 999.
- Returns:
- the rule for the milli-of-second field, never null
-
amPmOfDayRule
Gets the rule for the AM/PM of day field.This field defines the half-day AM/PM value. The hour-of-day from 0 to 11 is defined as AM, while the hours from 12 to 23 are defined as PM. AM is defined with the value 0, while PM is defined with the value 1.
The enum
AmPmOfDayshould be used wherever possible in applications when referring to the day of the week to avoid hard-coding the values.- Returns:
- the rule for the am/pm of day field, never null
-
hourOfAmPmRule
Gets the rule for the hour of AM/PM field from 0 to 11.This field counts hours sequentially from the start of the half-day AM/PM. The values run from 0 to 11.
- Returns:
- the rule for the hour of AM/PM field, never null
-
clockHourOfAmPmRule
Gets the rule for the clock hour of AM/PM field from 1 to 12.This field counts hours sequentially within the half-day AM/PM as normally seen on a clock or watch. The values run from 1 to 12.
- Returns:
- the rule for the hour of AM/PM field, never null
-
clockHourOfDayRule
Gets the rule for the clock hour of AM/PM field from 1 to 24.This field counts hours sequentially within the day starting from 1. The values run from 1 to 24.
- Returns:
- the rule for the clock-hour-of-day field, never null
-
epochDays
Gets the rule for the epoch-days field.This field counts seconds sequentially from the Java epoch of 1970-01-01.
- Returns:
- the rule for the epoch-days field, never null
-
nanoOfDayRule
Gets the rule for the nano-of-day field.This field counts seconds sequentially from the start of the day. The values run from 0 to 86,399,999,999,999.
- Returns:
- the rule for the nano-of-day field, never null
-
periodEras
Gets the period unit for eras.The period unit defines the concept of a period of a eras. An era, based on a simple before/after point on the time-line, is infinite in length. For this rule, an era has an estimated duration of 2,000,000,000 years.
This is a basic unit and has no equivalent period. The estimated duration is equal to 2,000,000,000 years.
- Returns:
- the period unit for eras, never null
-
periodMillennia
Gets the period unit for millennia of 1000 years.The period unit defines the concept of a period of a century.
The equivalent period and estimated duration are equal to 10 centuries.
- Returns:
- the period unit for millennia, never null
-
periodCenturies
Gets the period unit for centuries of 100 years.The period unit defines the concept of a period of a century.
The equivalent period and estimated duration are equal to 10 decades.
- Returns:
- the period unit for centuries, never null
-
periodDecades
Gets the period unit for decades of 10 years.The period unit defines the concept of a period of a decade.
The equivalent period and estimated duration are equal to 10 years.
- Returns:
- the period unit for decades, never null
-
periodYears
Gets the period unit for years of 12 months.The period unit defines the concept of a period of a year.
The equivalent period and estimated duration are equal to 4 quarters.
See
yearRule()for the main date-time field.- Returns:
- the period unit for years, never null
-
periodWeekBasedYears
Gets the period unit for week-based-years.The period unit defines the concept of a period of a week-based-year. This is typically 52 weeks, and occasionally 53 weeks.
This is a basic unit and has no equivalent period. The estimated duration is equal to 364.5 days, which is just over 5 weeks.
See
weekBasedYearRule()for the main date-time field.- Returns:
- the period unit for week-based-years, never null
-
periodQuarters
Gets the period unit for quarters of 3 months.The period unit defines the concept of a period of a quarter.
The equivalent period and estimated duration are equal to 3 months.
See
quarterOfYearRule()for the main date-time field.- Returns:
- the period unit for quarters, never null
-
periodMonths
Gets the period unit for months.The period unit defines the concept of a period of a month.
This is a basic unit and has no equivalent period. The estimated duration is equal to one-twelfth of a year based on 365.2425 days.
See
monthOfYearRule()for the main date-time field.- Returns:
- the period unit for months, never null
-
periodWeeks
Gets the period unit for weeks of 7 days.The period unit defines the concept of a period of a week.
The equivalent period and estimated duration are equal to 7 days.
See
weekOfWeekBasedYearRule()andweekOfYearRule()for the main date-time fields.- Returns:
- the period unit for weeks, never null
-
periodDays
Gets the period unit for days.The period unit defines the concept of a period of a day. This is typically equal to 24 hours, but may vary due to time-zone changes.
This chronology defines two units that could represent a day. This unit,
Days, represents a day that varies in length based on time-zone (daylight savings time) changes. It is a basic unit that cannot be converted to seconds, nanoseconds orDuration. By contrast, the24Hoursunit has a fixed length of exactly 24 hours allowing it to be converted to seconds, nanoseconds andDuration.This is a basic unit and has no equivalent period. The estimated duration is equal to 24 hours.
See
dayOfMonthRule()for the main date-time field.- Returns:
- the period unit for accurate, variable length, days, never null
-
period24Hours
Gets the period unit for twenty-four hours, that is often treated as a day.The period unit defines the concept of a period of exactly 24 hours that is often treated as a day. The unit name of "24Hours" is intended to convey the fact that this is primarily a 24 hour unit that happens to be used as a day unit on occasion. In most scenarios, the standard
Daysunit is more applicable and accurate.This chronology defines two units that could represent a day. This unit,
24Hours, represents a fixed length of exactly 24 hours, allowing it to be converted to seconds, nanoseconds andDuration. By contrast, theDaysunit varies in length based on time-zone (daylight savings time) changes and cannot be converted to seconds, nanoseconds orDuration.The equivalent period and estimated duration are equal to twice the 12 hours unit, making it also equivalent to 24 hours.
- Returns:
- the period unit for fixed, 24 hour, days, never null
-
period12Hours
Gets the period unit for twelve hours, as used by AM/PM.The period unit defines the concept of a period of 12 hours.
The equivalent period and estimated duration are equal to 12 hours.
See
amPmOfDayRule()for the main date-time field.- Returns:
- the period unit for twelve hours, never null
-
periodHours
Gets the period unit for hours of 60 minutes.The period unit defines the concept of a period of a hour.
The equivalent period and estimated duration are equal to 60 minutes.
See
hourOfDayRule()for the main date-time field.- Returns:
- the period unit for hours, never null
-
periodMinutes
Gets the period unit for minutes of 60 seconds.The period unit defines the concept of a period of a minute.
The equivalent period and estimated duration are equal to 60 seconds.
See
minuteOfHourRule()for the main date-time field.- Returns:
- the period unit for minutes, never null
-
periodSeconds
Gets the period unit for seconds.The period unit defines the concept of a period of a second.
The equivalent period and estimated duration are equal to 1000 milliseconds.
See
secondOfMinuteRule()for the main date-time field.- Returns:
- the period unit for seconds, never null
-
periodMillis
Gets the period unit for milliseconds.The period unit defines the concept of a period of a millisecond.
The equivalent period and estimated duration are equal to 1000 microseconds.
See
milliOfSecondRule()for the main date-time field.- Returns:
- the period unit for milliseconds, never null
-
periodMicros
Gets the period unit for microseconds.The period unit defines the concept of a period of a microsecond.
The equivalent period and estimated duration are equal to 1000 nanoseconds.
- Returns:
- the period unit for microseconds, never null
-
periodNanos
Gets the period unit for nanoseconds.The period unit defines the concept of a period of a nanosecond.
This is a basic unit and has no equivalent period. The estimated duration is 1 nanosecond.
See
nanoOfSecondRule()for the main date-time field.- Returns:
- the period unit for nanoseconds, never null
-