- java.lang.Object
-
- java.time.chrono.AbstractChronology
-
- org.threeten.extra.chrono.InternationalFixedChronology
-
- All Implemented Interfaces:
Serializable,Comparable<Chronology>,Chronology
public final class InternationalFixedChronology extends AbstractChronology implements Serializable
The International Fixed calendar system.This chronology defines the rules of the International Fixed calendar system. It shares the leap year rule with the Gregorian calendar. Dates are aligned such that
0001-01-01 (International Fixed)is0001-01-01 (ISO).This class is proleptic. It implements only years greater or equal to 1.
This class implements a calendar where January 1st is the start of the year.
The fields are defined as follows:
- era - There is only one era, the current 'Common Era' (CE).
- year-of-era - The year-of-era for the current era increases uniformly from the epoch at year 1.
- proleptic-year - The proleptic year is the same as the year-of-era for the current era.
- month-of-year - There are 13 months in an International Fixed year, numbered from 1 to 13.
- day-of-month - There are 28 days in a standard International Fixed month, numbered from 1 to 28, with day 29 used in months 6 and 12 (month 6 only has 29 days in a leap year).
- day-of-year - There are 365 days in a standard International Fixed year and 366 days in a leap year. The days are numbered accordingly.
- leap-year - Leap years occur every 4 years, but skips 3 out of four centuries, i.e. when the century is not divisible by 400. This is the same rule in use for the Gregorian calendar.
- Week day - every month starts on a Sunday. Leap-day and year-day are neither part of a week, nor of any month.
Implementation Requirements
This class is immutable and thread-safe.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static InternationalFixedChronologyINSTANCESingleton instance for the International fixed chronology.
-
Constructor Summary
Constructors Constructor Description InternationalFixedChronology()Deprecated.Use the singletonINSTANCEinstead.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InternationalFixedDatedate(int prolepticYear, int month, int dayOfMonth)Obtains a local date in International Fixed calendar system from the proleptic-year, month-of-year and day-of-month fields.InternationalFixedDatedate(Era era, int yearOfEra, int month, int dayOfMonth)Obtains a local date in International Fixed calendar system from the era, year-of-era, month-of-year and day-of-month fields.InternationalFixedDatedate(TemporalAccessor temporal)Obtains a International Fixed local date from another date-time object.InternationalFixedDatedateEpochDay(long epochDay)Obtains a local date in the International Fixed calendar system from the epoch-day.InternationalFixedDatedateNow()Obtains the current International Fixed local date from the system clock in the default time-zone.InternationalFixedDatedateNow(Clock clock)Obtains the current International Fixed local date from the specified clock.InternationalFixedDatedateNow(ZoneId zone)Obtains the current International Fixed local date from the system clock in the specified time-zone.InternationalFixedDatedateYearDay(int prolepticYear, int dayOfYear)Obtains a local date in International Fixed calendar system from the proleptic-year and day-of-year fields.InternationalFixedDatedateYearDay(Era era, int yearOfEra, int dayOfYear)Obtains a local date in International Fixed calendar system from the era, year-of-era and day-of-year fields.InternationalFixedEraeraOf(int eraValue)Creates the chronology era object from the numeric value.List<Era>eras()Gets the list of eras for the chronology.StringgetCalendarType()Gets the calendar type of the underlying calendar system, which returns null.StringgetId()Gets the ID of the chronology - 'Ifc'.booleanisLeapYear(long year)Checks if the specified year is a leap year.ChronoLocalDateTime<InternationalFixedDate>localDateTime(TemporalAccessor temporal)Obtains a International Fixed local date-time from another date-time object.intprolepticYear(Era era, int yearOfEra)ValueRangerange(ChronoField field)ChronoZonedDateTime<InternationalFixedDate>zonedDateTime(Instant instant, ZoneId zone)Obtains a International Fixed zoned date-time in this chronology from anInstant.ChronoZonedDateTime<InternationalFixedDate>zonedDateTime(TemporalAccessor temporal)Obtains a International Fixed zoned date-time from another date-time object.-
Methods inherited from class java.time.chrono.AbstractChronology
compareTo, equals, hashCode, resolveDate, 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 InternationalFixedChronology INSTANCE
Singleton instance for the International fixed chronology.
-
-
Constructor Detail
-
InternationalFixedChronology
@Deprecated public InternationalFixedChronology()
Deprecated.Use the singletonINSTANCEinstead.Private constructor, that is public to satisfy theServiceLoader.
-
-
Method Detail
-
getId
public String getId()
Gets the ID of the chronology - 'Ifc'.The ID uniquely identifies the
Chronology. It can be used to lookup theChronologyusingChronology.of(String).- Specified by:
getIdin interfaceChronology- Returns:
- the chronology ID - 'Ifc'
- See Also:
getCalendarType()
-
getCalendarType
public String getCalendarType()
Gets the calendar type of the underlying calendar system, which returns null.The Unicode Locale Data Markup Language (LDML) specification does not define an identifier for this calendar system, thus null is returned.
- Specified by:
getCalendarTypein interfaceChronology- Returns:
- the calendar system type, null
- See Also:
getId()
-
date
public InternationalFixedDate date(Era era, int yearOfEra, int month, int dayOfMonth)
Obtains a local date in International Fixed calendar system from the era, year-of-era, month-of-year and day-of-month fields.- Specified by:
datein interfaceChronology- Parameters:
era- the International Fixed era, not nullyearOfEra- the year-of-eramonth- the month-of-yeardayOfMonth- the day-of-month- Returns:
- the International Fixed local date, not null
- Throws:
DateTimeException- if unable to create the dateClassCastException- if theerais not aInternationalFixedEra
-
date
public InternationalFixedDate date(int prolepticYear, int month, int dayOfMonth)
Obtains a local date in International Fixed 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 International Fixed local date, not null
- Throws:
DateTimeException- if unable to create the date
-
dateYearDay
public InternationalFixedDate dateYearDay(Era era, int yearOfEra, int dayOfYear)
Obtains a local date in International Fixed calendar system from the era, year-of-era and day-of-year fields.- Specified by:
dateYearDayin interfaceChronology- Parameters:
era- the International Fixed era, not nullyearOfEra- the year-of-eradayOfYear- the day-of-year- Returns:
- the International Fixed local date, not null
- Throws:
DateTimeException- if unable to create the dateClassCastException- if theerais not aInternationalFixedEra
-
dateYearDay
public InternationalFixedDate dateYearDay(int prolepticYear, int dayOfYear)
Obtains a local date in International Fixed 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 International Fixed local date, not null
- Throws:
DateTimeException- if unable to create the date
-
dateEpochDay
public InternationalFixedDate dateEpochDay(long epochDay)
Obtains a local date in the International Fixed calendar system from the epoch-day.- Specified by:
dateEpochDayin interfaceChronology- Parameters:
epochDay- the epoch day- Returns:
- the International Fixed local date, not null
- Throws:
DateTimeException- if unable to create the date
-
dateNow
public InternationalFixedDate dateNow()
Obtains the current International Fixed 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 International Fixed local date using the system clock and default time-zone, not null
- Throws:
DateTimeException- if unable to create the date
-
dateNow
public InternationalFixedDate dateNow(ZoneId zone)
Obtains the current International Fixed 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 International Fixed local date using the system clock, not null
- Throws:
DateTimeException- if unable to create the date
-
dateNow
public InternationalFixedDate dateNow(Clock clock)
Obtains the current International Fixed 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 International Fixed local date, not null
- Throws:
DateTimeException- if unable to create the date
-
date
public InternationalFixedDate date(TemporalAccessor temporal)
Obtains a International Fixed local date from another date-time object.- Specified by:
datein interfaceChronology- Parameters:
temporal- the date-time object to convert, not null- Returns:
- the International Fixed local date, not null
- Throws:
DateTimeException- if unable to create the date
-
localDateTime
public ChronoLocalDateTime<InternationalFixedDate> localDateTime(TemporalAccessor temporal)
Obtains a International Fixed local date-time from another date-time object.- Specified by:
localDateTimein interfaceChronology- Parameters:
temporal- the date-time object to convert, not null- Returns:
- the International Fixed local date-time, not null
- Throws:
DateTimeException- if unable to create the date-time
-
zonedDateTime
public ChronoZonedDateTime<InternationalFixedDate> zonedDateTime(TemporalAccessor temporal)
Obtains a International Fixed zoned date-time from another date-time object.- Specified by:
zonedDateTimein interfaceChronology- Parameters:
temporal- the date-time object to convert, not null- Returns:
- the International Fixed zoned date-time, not null
- Throws:
DateTimeException- if unable to create the date-time
-
zonedDateTime
public ChronoZonedDateTime<InternationalFixedDate> zonedDateTime(Instant instant, ZoneId zone)
Obtains a International Fixed 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 International Fixed zoned date-time, not null
- Throws:
DateTimeException- if the result exceeds the supported range
-
isLeapYear
public boolean isLeapYear(long year)
Checks if the specified year is a leap year.A leap-year is a year of a longer length than normal. Leap years in the calendar system match those of the ISO calendar system.
- Specified by:
isLeapYearin interfaceChronology- Parameters:
year- the proleptic-year to check, not validated for range- Returns:
- true if the year is a leap year
-
eraOf
public InternationalFixedEra eraOf(int eraValue)
Creates the chronology era object from the numeric value.Only one era is supported, CE, with the value 1.
- Specified by:
eraOfin interfaceChronology- Parameters:
eraValue- the era value- Returns:
- the calendar system era, not null
- Throws:
DateTimeException- if unable to create the era
-
eras
public List<Era> eras()
Gets the list of eras for the chronology.Only one era is supported, CE, with the value 1.
- Specified by:
erasin interfaceChronology- Returns:
- the list of eras for the chronology, may be immutable, not null
-
range
public ValueRange range(ChronoField field)
- Specified by:
rangein interfaceChronology
-
prolepticYear
public int prolepticYear(Era era, int yearOfEra)
- Specified by:
prolepticYearin interfaceChronology
-
-