Class DiscordianChronology
- All Implemented Interfaces:
Serializable,Comparable<Chronology>,Chronology
This chronology defines the rules of the proleptic Discordian calendar system. The Discordian differs from the Gregorian in terms of month and week lengths, with an offset year. Dates are aligned such that each Discordian year starts with each ISO year, with an offset index.
This class is not proleptic. It implements Discordian rules only since YOLD 1 (ISO BCE 1166).
The fields are defined as follows:
- era - There is one era, the current 'Year of Our Lady of Discord' (YOLD).
- year-of-era - The year-of-era for the current era increases uniformly from the epoch at year one.
- proleptic-year - The proleptic year is the same as the year-of-era for the current era.
- month-of-year - There are 5 months in a Discordian year, numbered from 1 to 5.
- day-of-week - There are 5 days in a Discordian week, numbered from 1 to 5.
- day-of-month - There are 73 days in each Discordian month, numbered from 1 to 73.
- day-of-year - There are 365 days in a standard Discordian year and 366 in a leap year. The days are numbered from 1 to 365 or 1 to 366.
- leap-year - Leap years occur in sync with ISO leap-years; that is, they occur every 4 ISO years, excepting when that ISO year is divisible by 100 but not 400.
- St. Tib's Day - St. Tib's Day occurs each leap-year, and is inserted between the 59th and 60th day of the first month. St. Tib's Day is not part of any month, nor is it part of the Discordian week. It is aligned with the ISO calendar leap-day (February 29th).
Implementation Requirements
This class is immutable and thread-safe.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DiscordianChronologySingleton instance for the Discordian chronology. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondate(int prolepticYear, int month, int dayOfMonth) Obtains a local date in Discordian calendar system from the proleptic-year, month-of-year and day-of-month fields.Obtains a local date in Discordian calendar system from the era, year-of-era, month-of-year and day-of-month fields.date(TemporalAccessor temporal) Obtains a Discordian local date from another date-time object.dateEpochDay(long epochDay) Obtains a local date in the Discordian calendar system from the epoch-day.dateNow()Obtains the current Discordian local date from the system clock in the default time-zone.Obtains the current Discordian local date from the specified clock.Obtains the current Discordian local date from the system clock in the specified time-zone.dateYearDay(int prolepticYear, int dayOfYear) Obtains a local date in the Discordian calendar system from the proleptic-year and day-of-year fields.dateYearDay(Era era, int yearOfEra, int dayOfYear) Obtains a local date in Discordian calendar system from the era, year-of-era and day-of-year fields.eraOf(int era) eras()Gets the calendar type of the underlying calendar system - 'discordian'.getId()Gets the ID of the chronology - 'Discordian'.booleanisLeapYear(long prolepticYear) Checks if the specified year is a leap year.localDateTime(TemporalAccessor temporal) Obtains a Discordian local date-time from another date-time object.intprolepticYear(Era era, int yearOfEra) range(ChronoField field) resolveDate(Map<TemporalField, Long> fieldValues, ResolverStyle resolverStyle) zonedDateTime(Instant instant, ZoneId zone) Obtains a Discordian zoned date-time in this chronology from anInstant.zonedDateTime(TemporalAccessor temporal) Obtains a Discordian zoned date-time from another date-time object.Methods inherited from class java.time.chrono.AbstractChronology
compareTo, equals, hashCode, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.time.chrono.Chronology
getDisplayName, period
-
Field Details
-
INSTANCE
Singleton instance for the Discordian chronology.
-
-
Constructor Details
-
DiscordianChronology
Deprecated.Use the singletonINSTANCEinstead.Private constructor, that is public to satisfy theServiceLoader.
-
-
Method Details
-
getId
Gets the ID of the chronology - 'Discordian'.The ID uniquely identifies the
Chronology. It can be used to lookup theChronologyusingChronology.of(String).- Specified by:
getIdin interfaceChronology- Returns:
- the chronology ID - 'Discordian'
- See Also:
-
getCalendarType
Gets the calendar type of the underlying calendar system - 'discordian'.The Unicode Locale Data Markup Language (LDML) specification does not define an identifier for the Discordian calendar, but were it to do so, 'discordian' is highly likely to be chosen.
- Specified by:
getCalendarTypein interfaceChronology- Returns:
- the calendar system type - 'discordian'
- See Also:
-
date
Obtains a local date in Discordian calendar system from the era, year-of-era, month-of-year and day-of-month fields.- Specified by:
datein interfaceChronology- Parameters:
era- the Discordian era, not nullyearOfEra- the year-of-eramonth- the month-of-yeardayOfMonth- the day-of-month- Returns:
- the Discordian local date, not null
- Throws:
DateTimeException- if unable to create the dateClassCastException- if theerais not aDiscordianEra
-
date
Obtains a local date in Discordian calendar system from the proleptic-year, month-of-year and day-of-month fields.- Specified by:
datein interfaceChronology- Parameters:
prolepticYear- the proleptic-yearmonth- the month-of-yeardayOfMonth- the day-of-month- Returns:
- the Discordian local date, not null
- Throws:
DateTimeException- if unable to create the date
-
dateYearDay
Obtains a local date in Discordian calendar system from the era, year-of-era and day-of-year fields.- Specified by:
dateYearDayin interfaceChronology- Parameters:
era- the Discordian era, not nullyearOfEra- the year-of-eradayOfYear- the day-of-year- Returns:
- the Discordian local date, not null
- Throws:
DateTimeException- if unable to create the dateClassCastException- if theerais not aDiscordianEra
-
dateYearDay
Obtains a local date in the Discordian calendar system from the proleptic-year and day-of-year fields.- Specified by:
dateYearDayin interfaceChronology- Parameters:
prolepticYear- the proleptic-yeardayOfYear- the day-of-year- Returns:
- the Discordian local date, not null
- Throws:
DateTimeException- if unable to create the date
-
dateEpochDay
Obtains a local date in the Discordian calendar system from the epoch-day.- Specified by:
dateEpochDayin interfaceChronology- Parameters:
epochDay- the epoch day- Returns:
- the Discordian local date, not null
- Throws:
DateTimeException- if unable to create the date
-
dateNow
Obtains the current Discordian local date from the system clock in the default time-zone.This will query the
system clockin the default time-zone to obtain the current date.Using this method will prevent the ability to use an alternate clock for testing because the clock is hard-coded.
- Specified by:
dateNowin interfaceChronology- Returns:
- the current Discordian local date using the system clock and default time-zone, not null
- Throws:
DateTimeException- if unable to create the date
-
dateNow
Obtains the current Discordian local date from the system clock in the specified time-zone.This will query the
system clockto obtain the current date. Specifying the time-zone avoids dependence on the default time-zone.Using this method will prevent the ability to use an alternate clock for testing because the clock is hard-coded.
- Specified by:
dateNowin interfaceChronology- Parameters:
zone- the zone ID to use, not null- Returns:
- the current Discordian local date using the system clock, not null
- Throws:
DateTimeException- if unable to create the date
-
dateNow
Obtains the current Discordian local date from the specified clock.This will query the specified clock to obtain the current date - today. Using this method allows the use of an alternate clock for testing. The alternate clock may be introduced using
dependency injection.- Specified by:
dateNowin interfaceChronology- Parameters:
clock- the clock to use, not null- Returns:
- the current Discordian local date, not null
- Throws:
DateTimeException- if unable to create the date
-
date
Obtains a Discordian local date from another date-time object.- Specified by:
datein interfaceChronology- Parameters:
temporal- the date-time object to convert, not null- Returns:
- the Discordian local date, not null
- Throws:
DateTimeException- if unable to create the date
-
localDateTime
Obtains a Discordian local date-time from another date-time object.- Specified by:
localDateTimein interfaceChronology- Parameters:
temporal- the date-time object to convert, not null- Returns:
- the Discordian local date-time, not null
- Throws:
DateTimeException- if unable to create the date-time
-
zonedDateTime
Obtains a Discordian zoned date-time from another date-time object.- Specified by:
zonedDateTimein interfaceChronology- Parameters:
temporal- the date-time object to convert, not null- Returns:
- the Discordian zoned date-time, not null
- Throws:
DateTimeException- if unable to create the date-time
-
zonedDateTime
Obtains a Discordian zoned date-time in this chronology from anInstant.- Specified by:
zonedDateTimein interfaceChronology- Parameters:
instant- the instant to create the date-time from, not nullzone- the time-zone, not null- Returns:
- the Discordian zoned date-time, not null
- Throws:
DateTimeException- if the result exceeds the supported range
-
isLeapYear
public boolean isLeapYear(long prolepticYear) Checks if the specified year is a leap year.A Discordian proleptic-year is leap if the remainder after division by four equals zero. There are two special cases. If the year minus 1166 is divisible by 100 it is not a leap year, unless it is also divisible by 400, when it is a leap year. These rules produce leap days on the same dates as the ISO-8601 calendar system.
- Specified by:
isLeapYearin interfaceChronology- Parameters:
prolepticYear- the proleptic-year to check, not validated for range- Returns:
- true if the year is a leap year
-
prolepticYear
- Specified by:
prolepticYearin interfaceChronology
-
eraOf
- Specified by:
eraOfin interfaceChronology
-
eras
- Specified by:
erasin interfaceChronology
-
range
- Specified by:
rangein interfaceChronology
-
resolveDate
- Specified by:
resolveDatein interfaceChronology- Overrides:
resolveDatein classAbstractChronology
-
INSTANCEinstead.