- java.lang.Object
-
- java.time.chrono.AbstractChronology
-
- org.threeten.extra.chrono.CopticChronology
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<java.time.chrono.Chronology>,java.time.chrono.Chronology
public final class CopticChronology extends java.time.chrono.AbstractChronology implements java.io.SerializableThe Coptic calendar system.This chronology defines the rules of the Coptic calendar system. This calendar system is primarily used in Christian Egypt. Dates are aligned such that
0001-01-01 (Coptic)is0284-08-29 (ISO).The fields are defined as follows:
- era - There are two eras, the current 'Era of the Martyrs' (AM) and the previous era (BEFORE_AM).
- year-of-era - The year-of-era for the current era increases uniformly from the epoch at year one. For the previous era the year increases from one as time goes backwards.
- proleptic-year - The proleptic year is the same as the year-of-era for the current era. For the previous era, years have zero, then negative values.
- month-of-year - There are 13 months in a Coptic year, numbered from 1 to 13.
- day-of-month - There are 30 days in each of the first 12 Coptic months, numbered 1 to 30. The 13th month has 5 days, or 6 in a leap year, numbered 1 to 5 or 1 to 6.
- day-of-year - There are 365 days in a standard Coptic year and 366 in a leap year. The days are numbered from 1 to 365 or 1 to 366.
- leap-year - Leap years occur every 4 years.
Implementation Requirements
This class is immutable and thread-safe.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static CopticChronologyINSTANCESingleton instance for the Coptic chronology.
-
Constructor Summary
Constructors Constructor Description CopticChronology()Deprecated.Use the singletonINSTANCEinstead.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CopticDatedate(int prolepticYear, int month, int dayOfMonth)Obtains a local date in Coptic calendar system from the proleptic-year, month-of-year and day-of-month fields.CopticDatedate(java.time.chrono.Era era, int yearOfEra, int month, int dayOfMonth)Obtains a local date in Coptic calendar system from the era, year-of-era, month-of-year and day-of-month fields.CopticDatedate(java.time.temporal.TemporalAccessor temporal)Obtains a Coptic local date from another date-time object.CopticDatedateEpochDay(long epochDay)Obtains a local date in the Coptic calendar system from the epoch-day.CopticDatedateNow()Obtains the current Coptic local date from the system clock in the default time-zone.CopticDatedateNow(java.time.Clock clock)Obtains the current Coptic local date from the specified clock.CopticDatedateNow(java.time.ZoneId zone)Obtains the current Coptic local date from the system clock in the specified time-zone.CopticDatedateYearDay(int prolepticYear, int dayOfYear)Obtains a local date in Coptic calendar system from the proleptic-year and day-of-year fields.CopticDatedateYearDay(java.time.chrono.Era era, int yearOfEra, int dayOfYear)Obtains a local date in Coptic calendar system from the era, year-of-era and day-of-year fields.CopticEraeraOf(int eraValue)java.util.List<java.time.chrono.Era>eras()java.lang.StringgetCalendarType()Gets the calendar type of the underlying calendar system - 'coptic'.java.lang.StringgetId()Gets the ID of the chronology - 'Coptic'.booleanisLeapYear(long prolepticYear)Checks if the specified year is a leap year.java.time.chrono.ChronoLocalDateTime<CopticDate>localDateTime(java.time.temporal.TemporalAccessor temporal)Obtains a Coptic local date-time from another date-time object.intprolepticYear(java.time.chrono.Era era, int yearOfEra)java.time.temporal.ValueRangerange(java.time.temporal.ChronoField field)CopticDateresolveDate(java.util.Map<java.time.temporal.TemporalField,java.lang.Long> fieldValues, java.time.format.ResolverStyle resolverStyle)java.time.chrono.ChronoZonedDateTime<CopticDate>zonedDateTime(java.time.Instant instant, java.time.ZoneId zone)Obtains a Coptic zoned date-time in this chronology from anInstant.java.time.chrono.ChronoZonedDateTime<CopticDate>zonedDateTime(java.time.temporal.TemporalAccessor temporal)Obtains a Coptic zoned date-time from another date-time object.-
Methods inherited from class java.time.chrono.AbstractChronology
compareTo, equals, hashCode, toString
-
-
-
-
Field Detail
-
INSTANCE
public static final CopticChronology INSTANCE
Singleton instance for the Coptic chronology.
-
-
Constructor Detail
-
CopticChronology
@Deprecated public CopticChronology()
Deprecated.Use the singletonINSTANCEinstead.Private constructor, that is public to satisfy theServiceLoader.
-
-
Method Detail
-
getId
public java.lang.String getId()
Gets the ID of the chronology - 'Coptic'.The ID uniquely identifies the
Chronology. It can be used to lookup theChronologyusingChronology.of(String).- Specified by:
getIdin interfacejava.time.chrono.Chronology- Returns:
- the chronology ID - 'Coptic'
- See Also:
getCalendarType()
-
getCalendarType
public java.lang.String getCalendarType()
Gets the calendar type of the underlying calendar system - 'coptic'.The calendar type is an identifier defined by the Unicode Locale Data Markup Language (LDML) specification. It can be used to lookup the
ChronologyusingChronology.of(String). It can also be used as part of a locale, accessible viaLocale.getUnicodeLocaleType(String)with the key 'ca'.- Specified by:
getCalendarTypein interfacejava.time.chrono.Chronology- Returns:
- the calendar system type - 'coptic'
- See Also:
getId()
-
date
public CopticDate date(java.time.chrono.Era era, int yearOfEra, int month, int dayOfMonth)
Obtains a local date in Coptic calendar system from the era, year-of-era, month-of-year and day-of-month fields.- Specified by:
datein interfacejava.time.chrono.Chronology- Parameters:
era- the Coptic era, not nullyearOfEra- the year-of-eramonth- the month-of-yeardayOfMonth- the day-of-month- Returns:
- the Coptic local date, not null
- Throws:
java.time.DateTimeException- if unable to create the datejava.lang.ClassCastException- if theerais not aCopticEra
-
date
public CopticDate date(int prolepticYear, int month, int dayOfMonth)
Obtains a local date in Coptic calendar system from the proleptic-year, month-of-year and day-of-month fields.- Specified by:
datein interfacejava.time.chrono.Chronology- Parameters:
prolepticYear- the proleptic-yearmonth- the month-of-yeardayOfMonth- the day-of-month- Returns:
- the Coptic local date, not null
- Throws:
java.time.DateTimeException- if unable to create the date
-
dateYearDay
public CopticDate dateYearDay(java.time.chrono.Era era, int yearOfEra, int dayOfYear)
Obtains a local date in Coptic calendar system from the era, year-of-era and day-of-year fields.- Specified by:
dateYearDayin interfacejava.time.chrono.Chronology- Parameters:
era- the Coptic era, not nullyearOfEra- the year-of-eradayOfYear- the day-of-year- Returns:
- the Coptic local date, not null
- Throws:
java.time.DateTimeException- if unable to create the datejava.lang.ClassCastException- if theerais not aCopticEra
-
dateYearDay
public CopticDate dateYearDay(int prolepticYear, int dayOfYear)
Obtains a local date in Coptic calendar system from the proleptic-year and day-of-year fields.- Specified by:
dateYearDayin interfacejava.time.chrono.Chronology- Parameters:
prolepticYear- the proleptic-yeardayOfYear- the day-of-year- Returns:
- the Coptic local date, not null
- Throws:
java.time.DateTimeException- if unable to create the date
-
dateEpochDay
public CopticDate dateEpochDay(long epochDay)
Obtains a local date in the Coptic calendar system from the epoch-day.- Specified by:
dateEpochDayin interfacejava.time.chrono.Chronology- Parameters:
epochDay- the epoch day- Returns:
- the Coptic local date, not null
- Throws:
java.time.DateTimeException- if unable to create the date
-
dateNow
public CopticDate dateNow()
Obtains the current Coptic 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 interfacejava.time.chrono.Chronology- Returns:
- the current Coptic local date using the system clock and default time-zone, not null
- Throws:
java.time.DateTimeException- if unable to create the date
-
dateNow
public CopticDate dateNow(java.time.ZoneId zone)
Obtains the current Coptic 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 interfacejava.time.chrono.Chronology- Parameters:
zone- the zone ID to use, not null- Returns:
- the current Coptic local date using the system clock, not null
- Throws:
java.time.DateTimeException- if unable to create the date
-
dateNow
public CopticDate dateNow(java.time.Clock clock)
Obtains the current Coptic 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 interfacejava.time.chrono.Chronology- Parameters:
clock- the clock to use, not null- Returns:
- the current Coptic local date, not null
- Throws:
java.time.DateTimeException- if unable to create the date
-
date
public CopticDate date(java.time.temporal.TemporalAccessor temporal)
Obtains a Coptic local date from another date-time object.- Specified by:
datein interfacejava.time.chrono.Chronology- Parameters:
temporal- the date-time object to convert, not null- Returns:
- the Coptic local date, not null
- Throws:
java.time.DateTimeException- if unable to create the date
-
localDateTime
public java.time.chrono.ChronoLocalDateTime<CopticDate> localDateTime(java.time.temporal.TemporalAccessor temporal)
Obtains a Coptic local date-time from another date-time object.- Specified by:
localDateTimein interfacejava.time.chrono.Chronology- Parameters:
temporal- the date-time object to convert, not null- Returns:
- the Coptic local date-time, not null
- Throws:
java.time.DateTimeException- if unable to create the date-time
-
zonedDateTime
public java.time.chrono.ChronoZonedDateTime<CopticDate> zonedDateTime(java.time.temporal.TemporalAccessor temporal)
Obtains a Coptic zoned date-time from another date-time object.- Specified by:
zonedDateTimein interfacejava.time.chrono.Chronology- Parameters:
temporal- the date-time object to convert, not null- Returns:
- the Coptic zoned date-time, not null
- Throws:
java.time.DateTimeException- if unable to create the date-time
-
zonedDateTime
public java.time.chrono.ChronoZonedDateTime<CopticDate> zonedDateTime(java.time.Instant instant, java.time.ZoneId zone)
Obtains a Coptic zoned date-time in this chronology from anInstant.- Specified by:
zonedDateTimein interfacejava.time.chrono.Chronology- Parameters:
instant- the instant to create the date-time from, not nullzone- the time-zone, not null- Returns:
- the Coptic zoned date-time, not null
- Throws:
java.time.DateTimeException- if the result exceeds the supported range
-
prolepticYear
public int prolepticYear(java.time.chrono.Era era, int yearOfEra)- Specified by:
prolepticYearin interfacejava.time.chrono.Chronology
-
eraOf
public CopticEra eraOf(int eraValue)
- Specified by:
eraOfin interfacejava.time.chrono.Chronology
-
eras
public java.util.List<java.time.chrono.Era> eras()
- Specified by:
erasin interfacejava.time.chrono.Chronology
-
resolveDate
public CopticDate resolveDate(java.util.Map<java.time.temporal.TemporalField,java.lang.Long> fieldValues, java.time.format.ResolverStyle resolverStyle)
- Specified by:
resolveDatein interfacejava.time.chrono.Chronology- Overrides:
resolveDatein classjava.time.chrono.AbstractChronology
-
isLeapYear
public boolean isLeapYear(long prolepticYear)
Checks if the specified year is a leap year.The proleptic-year is leap if the remainder after division by four equals three. This method does not validate the year passed in, and only has a well-defined result for years in the supported range.
- Parameters:
prolepticYear- the proleptic-year to check, not validated for range- Returns:
- true if the year is a leap year
-
range
public java.time.temporal.ValueRange range(java.time.temporal.ChronoField field)
-
-