Class ISOChronology
- java.lang.Object
-
- javax.time.calendar.Chronology
-
- javax.time.calendar.ISOChronology
-
- All Implemented Interfaces:
Serializable
,Calendrical
public final class ISOChronology extends Chronology implements Serializable
The ISO-8601 calendar system, which follows the rules of the current de facto world calendar.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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static ISOChronology
INSTANCE
The singleton instance ofISOChronology
.static int
MAX_WEEK_BASED_YEAR
Constant for the maximum week-based-year.static int
MIN_WEEK_BASED_YEAR
Constant for the minimum week-based-year.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DateTimeFieldRule<AmPmOfDay>
amPmOfDayRule()
Gets the rule for the AM/PM of day field.static DateTimeFieldRule<Integer>
clockHourOfAmPmRule()
Gets the rule for the clock hour of AM/PM field from 1 to 12.static DateTimeFieldRule<Integer>
clockHourOfDayRule()
Gets the rule for the clock hour of AM/PM field from 1 to 24.static DateTimeFieldRule<Integer>
dayOfMonthRule()
Gets the rule for the day-of-month field in the ISO chronology.static DateTimeFieldRule<DayOfWeek>
dayOfWeekRule()
Gets the rule for the day-of-week field.static DateTimeFieldRule<Integer>
dayOfYearRule()
Gets the rule for the day-of-year field in the ISO chronology.static CalendricalRule<Long>
epochDays()
Gets the rule for the epoch-days field.String
getName()
Gets the name of the chronology.static DateTimeFieldRule<Integer>
hourOfAmPmRule()
Gets the rule for the hour of AM/PM field from 0 to 11.static DateTimeFieldRule<Integer>
hourOfDayRule()
Gets the rule for the hour-of-day field.static boolean
isLeapYear(int year)
Checks if the specified year is a leap year according to the ISO calendar system rules.static DateTimeFieldRule<Integer>
milliOfDayRule()
Gets the rule for the milli-of-day field.static DateTimeFieldRule<Integer>
milliOfSecondRule()
Gets the rule for the milli-of-second field.static DateTimeFieldRule<Integer>
minuteOfHourRule()
Gets the rule for the minute-of-hour field.static DateTimeFieldRule<Integer>
monthOfQuarterRule()
Gets the rule for the month-of-quarter field in the ISO chronology.static DateTimeFieldRule<MonthOfYear>
monthOfYearRule()
Gets the rule for the month-of-year field in the ISO chronology.static CalendricalRule<Long>
nanoOfDayRule()
Gets the rule for the nano-of-day field.static DateTimeFieldRule<Integer>
nanoOfSecondRule()
Gets the rule for the nano-of-second field.static PeriodUnit
period12Hours()
Gets the period unit for twelve hours, as used by AM/PM.static PeriodUnit
period24Hours()
Gets the period unit for twenty-four hours, that is often treated as a day.static PeriodUnit
periodCenturies()
Gets the period unit for centuries of 100 years.static PeriodUnit
periodDays()
Gets the period unit for days.static PeriodUnit
periodDecades()
Gets the period unit for decades of 10 years.static PeriodUnit
periodEras()
Gets the period unit for eras.static PeriodUnit
periodHours()
Gets the period unit for hours of 60 minutes.static PeriodUnit
periodMicros()
Gets the period unit for microseconds.static PeriodUnit
periodMillennia()
Gets the period unit for millennia of 1000 years.static PeriodUnit
periodMillis()
Gets the period unit for milliseconds.static PeriodUnit
periodMinutes()
Gets the period unit for minutes of 60 seconds.static PeriodUnit
periodMonths()
Gets the period unit for months.static PeriodUnit
periodNanos()
Gets the period unit for nanoseconds.static PeriodUnit
periodQuarters()
Gets the period unit for quarters of 3 months.static PeriodUnit
periodSeconds()
Gets the period unit for seconds.static PeriodUnit
periodWeekBasedYears()
Gets the period unit for week-based-years.static PeriodUnit
periodWeeks()
Gets the period unit for weeks of 7 days.static PeriodUnit
periodYears()
Gets the period unit for years of 12 months.static DateTimeFieldRule<QuarterOfYear>
quarterOfYearRule()
Gets the rule for the quarter-of-year field in the ISO chronology.static DateTimeFieldRule<Integer>
secondOfDayRule()
Gets the rule for the second-of-day field.static DateTimeFieldRule<Integer>
secondOfMinuteRule()
Gets the rule for the second-of-minute field.static DateTimeFieldRule<Integer>
weekBasedYearRule()
Gets the rule for the week-based-year field in the ISO chronology.static DateTimeFieldRule<Integer>
weekOfMonthRule()
Gets the rule for the week-of-month field in the ISO chronology.static DateTimeFieldRule<Integer>
weekOfWeekBasedYearRule()
Gets the rule for the week-of-week-based-year field in the ISO chronology.static DateTimeFieldRule<Integer>
weekOfYearRule()
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 javax.time.calendar.Chronology
get, rule, toString
-
-
-
-
Field Detail
-
INSTANCE
public static final ISOChronology INSTANCE
The singleton instance ofISOChronology
.
-
MIN_WEEK_BASED_YEAR
public static final int MIN_WEEK_BASED_YEAR
Constant for the minimum week-based-year.- See Also:
- Constant Field Values
-
MAX_WEEK_BASED_YEAR
public static final int MAX_WEEK_BASED_YEAR
Constant for the maximum week-based-year.- See Also:
- Constant Field Values
-
-
Method Detail
-
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
public String getName()
Gets the name of the chronology.- Specified by:
getName
in classChronology
- Returns:
- the name of the chronology, never null
-
yearRule
public static DateTimeFieldRule<Integer> 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
public static DateTimeFieldRule<MonthOfYear> 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
MonthOfYear
should 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
public static DateTimeFieldRule<Integer> 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
public static DateTimeFieldRule<Integer> 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
public static DateTimeFieldRule<Integer> 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-year
for 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
public static DateTimeFieldRule<Integer> 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
public static DateTimeFieldRule<DayOfWeek> 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
DayOfWeek
should 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
public static DateTimeFieldRule<Integer> 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
public static DateTimeFieldRule<QuarterOfYear> 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
public static DateTimeFieldRule<Integer> 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
public static DateTimeFieldRule<Integer> 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
DateTimeFields
instance using this rule and theday-of-week
rule.- Returns:
- the rule for the week-of-month field, never null
-
hourOfDayRule
public static DateTimeFieldRule<Integer> 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
public static DateTimeFieldRule<Integer> 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
public static DateTimeFieldRule<Integer> 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
public static DateTimeFieldRule<Integer> 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
public static DateTimeFieldRule<Integer> 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
public static DateTimeFieldRule<Integer> 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
public static DateTimeFieldRule<Integer> 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
public static DateTimeFieldRule<AmPmOfDay> 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
AmPmOfDay
should 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
public static DateTimeFieldRule<Integer> 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
public static DateTimeFieldRule<Integer> 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
public static DateTimeFieldRule<Integer> 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
public static CalendricalRule<Long> 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
public static CalendricalRule<Long> 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
public static PeriodUnit 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
public static PeriodUnit 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
public static PeriodUnit 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
public static PeriodUnit 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
public static PeriodUnit 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
public static PeriodUnit 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
public static PeriodUnit 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
public static PeriodUnit 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
public static PeriodUnit 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
public static PeriodUnit 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, the24Hours
unit 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
public static PeriodUnit 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
Days
unit 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, theDays
unit 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
public static PeriodUnit 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
public static PeriodUnit 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
public static PeriodUnit 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
public static PeriodUnit 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
public static PeriodUnit 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
public static PeriodUnit 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
public static PeriodUnit 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
-
-