- java.lang.Object
-
- java.time.chrono.AbstractChronology
-
- org.threeten.extra.chrono.EthiopicChronology
-
- All Implemented Interfaces:
Serializable
,Comparable<Chronology>
,Chronology
public final class EthiopicChronology extends AbstractChronology implements Serializable
The Ethiopic calendar system.This chronology defines the rules of the Ethiopic calendar system. This calendar system is primarily used in Ethiopia. Dates are aligned such that
0001-01-01 (Ethiopic)
is0284-08-29 (ISO)
.The fields are defined as follows:
- era - There are two eras, the current 'Incarnation Era' (INCARNATION) and the previous era (BEFORE_INCARNATION).
- 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 Ethiopic year, numbered from 1 to 13.
- day-of-month - There are 30 days in each of the first 12 Ethiopic 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 Ethiopic 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 EthiopicChronology
INSTANCE
Singleton instance for the Ethiopic chronology.
-
Constructor Summary
Constructors Constructor Description EthiopicChronology()
Deprecated.Use the singletonINSTANCE
instead.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EthiopicDate
date(int prolepticYear, int month, int dayOfMonth)
Obtains a local date in Ethiopic calendar system from the proleptic-year, month-of-year and day-of-month fields.EthiopicDate
date(Era era, int yearOfEra, int month, int dayOfMonth)
Obtains a local date in Ethiopic calendar system from the era, year-of-era, month-of-year and day-of-month fields.EthiopicDate
date(TemporalAccessor temporal)
Obtains a Ethiopic local date from another date-time object.EthiopicDate
dateEpochDay(long epochDay)
Obtains a local date in the Ethiopic calendar system from the epoch-day.EthiopicDate
dateNow()
Obtains the current Ethiopic local date from the system clock in the default time-zone.EthiopicDate
dateNow(Clock clock)
Obtains the current Ethiopic local date from the specified clock.EthiopicDate
dateNow(ZoneId zone)
Obtains the current Ethiopic local date from the system clock in the specified time-zone.EthiopicDate
dateYearDay(int prolepticYear, int dayOfYear)
Obtains a local date in Ethiopic calendar system from the proleptic-year and day-of-year fields.EthiopicDate
dateYearDay(Era era, int yearOfEra, int dayOfYear)
Obtains a local date in Ethiopic calendar system from the era, year-of-era and day-of-year fields.EthiopicEra
eraOf(int eraValue)
List<Era>
eras()
String
getCalendarType()
Gets the calendar type of the underlying calendar system - 'ethiopic'.String
getId()
Gets the ID of the chronology - 'Ethiopic'.boolean
isLeapYear(long prolepticYear)
Checks if the specified year is a leap year.ChronoLocalDateTime<EthiopicDate>
localDateTime(TemporalAccessor temporal)
Obtains a Ethiopic local date-time from another date-time object.int
prolepticYear(Era era, int yearOfEra)
ValueRange
range(ChronoField field)
EthiopicDate
resolveDate(Map<TemporalField,Long> fieldValues, ResolverStyle resolverStyle)
ChronoZonedDateTime<EthiopicDate>
zonedDateTime(Instant instant, ZoneId zone)
Obtains a Ethiopic zoned date-time in this chronology from anInstant
.ChronoZonedDateTime<EthiopicDate>
zonedDateTime(TemporalAccessor temporal)
Obtains a Ethiopic zoned date-time from another date-time object.-
Methods inherited from class java.time.chrono.AbstractChronology
compareTo, equals, hashCode, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.time.chrono.Chronology
epochSecond, epochSecond, getDisplayName, period
-
-
-
-
Field Detail
-
INSTANCE
public static final EthiopicChronology INSTANCE
Singleton instance for the Ethiopic chronology.
-
-
Constructor Detail
-
EthiopicChronology
@Deprecated public EthiopicChronology()
Deprecated.Use the singletonINSTANCE
instead.Private constructor, that is public to satisfy theServiceLoader
.
-
-
Method Detail
-
getId
public String getId()
Gets the ID of the chronology - 'Ethiopic'.The ID uniquely identifies the
Chronology
. It can be used to lookup theChronology
usingChronology.of(String)
.- Specified by:
getId
in interfaceChronology
- Returns:
- the chronology ID - 'Ethiopic'
- See Also:
getCalendarType()
-
getCalendarType
public String getCalendarType()
Gets the calendar type of the underlying calendar system - 'ethiopic'.The calendar type is an identifier defined by the Unicode Locale Data Markup Language (LDML) specification. It can be used to lookup the
Chronology
usingChronology.of(String)
. It can also be used as part of a locale, accessible viaLocale.getUnicodeLocaleType(String)
with the key 'ca'.- Specified by:
getCalendarType
in interfaceChronology
- Returns:
- the calendar system type - 'ethiopic'
- See Also:
getId()
-
date
public EthiopicDate date(Era era, int yearOfEra, int month, int dayOfMonth)
Obtains a local date in Ethiopic calendar system from the era, year-of-era, month-of-year and day-of-month fields.- Specified by:
date
in interfaceChronology
- Parameters:
era
- the Ethiopic era, not nullyearOfEra
- the year-of-eramonth
- the month-of-yeardayOfMonth
- the day-of-month- Returns:
- the Ethiopic local date, not null
- Throws:
DateTimeException
- if unable to create the dateClassCastException
- if theera
is not aEthiopicEra
-
date
public EthiopicDate date(int prolepticYear, int month, int dayOfMonth)
Obtains a local date in Ethiopic calendar system from the proleptic-year, month-of-year and day-of-month fields.- Specified by:
date
in interfaceChronology
- Parameters:
prolepticYear
- the proleptic-yearmonth
- the month-of-yeardayOfMonth
- the day-of-month- Returns:
- the Ethiopic local date, not null
- Throws:
DateTimeException
- if unable to create the date
-
dateYearDay
public EthiopicDate dateYearDay(Era era, int yearOfEra, int dayOfYear)
Obtains a local date in Ethiopic calendar system from the era, year-of-era and day-of-year fields.- Specified by:
dateYearDay
in interfaceChronology
- Parameters:
era
- the Ethiopic era, not nullyearOfEra
- the year-of-eradayOfYear
- the day-of-year- Returns:
- the Ethiopic local date, not null
- Throws:
DateTimeException
- if unable to create the dateClassCastException
- if theera
is not aEthiopicEra
-
dateYearDay
public EthiopicDate dateYearDay(int prolepticYear, int dayOfYear)
Obtains a local date in Ethiopic calendar system from the proleptic-year and day-of-year fields.- Specified by:
dateYearDay
in interfaceChronology
- Parameters:
prolepticYear
- the proleptic-yeardayOfYear
- the day-of-year- Returns:
- the Ethiopic local date, not null
- Throws:
DateTimeException
- if unable to create the date
-
dateEpochDay
public EthiopicDate dateEpochDay(long epochDay)
Obtains a local date in the Ethiopic calendar system from the epoch-day.- Specified by:
dateEpochDay
in interfaceChronology
- Parameters:
epochDay
- the epoch day- Returns:
- the Ethiopic local date, not null
- Throws:
DateTimeException
- if unable to create the date
-
dateNow
public EthiopicDate dateNow()
Obtains the current Ethiopic local date from the system clock in the default time-zone.This will query the
system clock
in 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:
dateNow
in interfaceChronology
- Returns:
- the current Ethiopic local date using the system clock and default time-zone, not null
- Throws:
DateTimeException
- if unable to create the date
-
dateNow
public EthiopicDate dateNow(ZoneId zone)
Obtains the current Ethiopic local date from the system clock in the specified time-zone.This will query the
system clock
to 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:
dateNow
in interfaceChronology
- Parameters:
zone
- the zone ID to use, not null- Returns:
- the current Ethiopic local date using the system clock, not null
- Throws:
DateTimeException
- if unable to create the date
-
dateNow
public EthiopicDate dateNow(Clock clock)
Obtains the current Ethiopic 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:
dateNow
in interfaceChronology
- Parameters:
clock
- the clock to use, not null- Returns:
- the current Ethiopic local date, not null
- Throws:
DateTimeException
- if unable to create the date
-
date
public EthiopicDate date(TemporalAccessor temporal)
Obtains a Ethiopic local date from another date-time object.- Specified by:
date
in interfaceChronology
- Parameters:
temporal
- the date-time object to convert, not null- Returns:
- the Ethiopic local date, not null
- Throws:
DateTimeException
- if unable to create the date
-
localDateTime
public ChronoLocalDateTime<EthiopicDate> localDateTime(TemporalAccessor temporal)
Obtains a Ethiopic local date-time from another date-time object.- Specified by:
localDateTime
in interfaceChronology
- Parameters:
temporal
- the date-time object to convert, not null- Returns:
- the Ethiopic local date-time, not null
- Throws:
DateTimeException
- if unable to create the date-time
-
zonedDateTime
public ChronoZonedDateTime<EthiopicDate> zonedDateTime(TemporalAccessor temporal)
Obtains a Ethiopic zoned date-time from another date-time object.- Specified by:
zonedDateTime
in interfaceChronology
- Parameters:
temporal
- the date-time object to convert, not null- Returns:
- the Ethiopic zoned date-time, not null
- Throws:
DateTimeException
- if unable to create the date-time
-
zonedDateTime
public ChronoZonedDateTime<EthiopicDate> zonedDateTime(Instant instant, ZoneId zone)
Obtains a Ethiopic zoned date-time in this chronology from anInstant
.- Specified by:
zonedDateTime
in interfaceChronology
- Parameters:
instant
- the instant to create the date-time from, not nullzone
- the time-zone, not null- Returns:
- the Ethiopic zoned date-time, not null
- Throws:
DateTimeException
- if the result exceeds the supported range
-
prolepticYear
public int prolepticYear(Era era, int yearOfEra)
- Specified by:
prolepticYear
in interfaceChronology
-
eraOf
public EthiopicEra eraOf(int eraValue)
- Specified by:
eraOf
in interfaceChronology
-
eras
public List<Era> eras()
- Specified by:
eras
in interfaceChronology
-
resolveDate
public EthiopicDate resolveDate(Map<TemporalField,Long> fieldValues, ResolverStyle resolverStyle)
- Specified by:
resolveDate
in interfaceChronology
- Overrides:
resolveDate
in classAbstractChronology
-
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 ValueRange range(ChronoField field)
-
-