- java.lang.Object
-
- java.time.chrono.AbstractChronology
-
- org.threeten.extra.chrono.JulianChronology
-
- All Implemented Interfaces:
Serializable,Comparable<Chronology>,Chronology
public final class JulianChronology extends AbstractChronology implements Serializable
The Julian calendar system.This chronology defines the rules of the proleptic Julian calendar system. This calendar system is the forerunner to the modern Gregorian and ISO calendars. The Julian differs from the Gregorian only in terms of the leap year rule. Dates are aligned such that
0001-01-01 (Julian)is0000-12-30 (ISO).This class is proleptic. It implements Julian rules to the entire time-line.
This class implements a calendar where January 1st is the start of the year. The history of the start of the year is complex and using the current standard is the most consistent.
The fields are defined as follows:
- era - There are two eras, the current 'Anno Domini' (AD) and the previous era 'Before Christ' (BC).
- 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 12 months in a Julian year, numbered from 1 to 12.
- day-of-month - There are between 28 and 31 days in each Julian month, numbered from 1 to 31. Months 4, 6, 9 and 11 have 30 days, Months 1, 3, 5, 7, 8, 10 and 12 have 31 days. Month 2 has 28 days, or 29 in a leap year.
- day-of-year - There are 365 days in a standard Julian 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 JulianChronologyINSTANCESingleton instance for the Julian chronology.
-
Constructor Summary
Constructors Constructor Description JulianChronology()Deprecated.Use the singletonINSTANCEinstead.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JulianDatedate(int prolepticYear, int month, int dayOfMonth)Obtains a local date in Julian calendar system from the proleptic-year, month-of-year and day-of-month fields.JulianDatedate(Era era, int yearOfEra, int month, int dayOfMonth)Obtains a local date in Julian calendar system from the era, year-of-era, month-of-year and day-of-month fields.JulianDatedate(TemporalAccessor temporal)Obtains a Julian local date from another date-time object.JulianDatedateEpochDay(long epochDay)Obtains a local date in the Julian calendar system from the epoch-day.JulianDatedateNow()Obtains the current Julian local date from the system clock in the default time-zone.JulianDatedateNow(Clock clock)Obtains the current Julian local date from the specified clock.JulianDatedateNow(ZoneId zone)Obtains the current Julian local date from the system clock in the specified time-zone.JulianDatedateYearDay(int prolepticYear, int dayOfYear)Obtains a local date in Julian calendar system from the proleptic-year and day-of-year fields.JulianDatedateYearDay(Era era, int yearOfEra, int dayOfYear)Obtains a local date in Julian calendar system from the era, year-of-era and day-of-year fields.JulianEraeraOf(int eraValue)List<Era>eras()StringgetCalendarType()Gets the calendar type of the underlying calendar system - 'julian'.StringgetId()Gets the ID of the chronology - 'Julian'.booleanisLeapYear(long prolepticYear)Checks if the specified year is a leap year.ChronoLocalDateTime<JulianDate>localDateTime(TemporalAccessor temporal)Obtains a Julian local date-time from another date-time object.intprolepticYear(Era era, int yearOfEra)ValueRangerange(ChronoField field)JulianDateresolveDate(Map<TemporalField,Long> fieldValues, ResolverStyle resolverStyle)ChronoZonedDateTime<JulianDate>zonedDateTime(Instant instant, ZoneId zone)Obtains a Julian zoned date-time in this chronology from anInstant.ChronoZonedDateTime<JulianDate>zonedDateTime(TemporalAccessor temporal)Obtains a Julian 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 JulianChronology INSTANCE
Singleton instance for the Julian chronology.
-
-
Constructor Detail
-
JulianChronology
@Deprecated public JulianChronology()
Deprecated.Use the singletonINSTANCEinstead.Private constructor, that is public to satisfy theServiceLoader.
-
-
Method Detail
-
getId
public String getId()
Gets the ID of the chronology - 'Julian'.The ID uniquely identifies the
Chronology. It can be used to lookup theChronologyusingChronology.of(String).- Specified by:
getIdin interfaceChronology- Returns:
- the chronology ID - 'Julian'
- See Also:
getCalendarType()
-
getCalendarType
public String getCalendarType()
Gets the calendar type of the underlying calendar system - 'julian'.The Unicode Locale Data Markup Language (LDML) specification does not define an identifier for the Julian calendar, but were it to do so, 'julian' is highly likely to be chosen.
- Specified by:
getCalendarTypein interfaceChronology- Returns:
- the calendar system type - 'julian'
- See Also:
getId()
-
date
public JulianDate date(Era era, int yearOfEra, int month, int dayOfMonth)
Obtains a local date in Julian calendar system from the era, year-of-era, month-of-year and day-of-month fields.- Specified by:
datein interfaceChronology- Parameters:
era- the Julian era, not nullyearOfEra- the year-of-eramonth- the month-of-yeardayOfMonth- the day-of-month- Returns:
- the Julian local date, not null
- Throws:
DateTimeException- if unable to create the dateClassCastException- if theerais not aJulianEra
-
date
public JulianDate date(int prolepticYear, int month, int dayOfMonth)
Obtains a local date in Julian 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 Julian local date, not null
- Throws:
DateTimeException- if unable to create the date
-
dateYearDay
public JulianDate dateYearDay(Era era, int yearOfEra, int dayOfYear)
Obtains a local date in Julian calendar system from the era, year-of-era and day-of-year fields.- Specified by:
dateYearDayin interfaceChronology- Parameters:
era- the Julian era, not nullyearOfEra- the year-of-eradayOfYear- the day-of-year- Returns:
- the Julian local date, not null
- Throws:
DateTimeException- if unable to create the dateClassCastException- if theerais not aJulianEra
-
dateYearDay
public JulianDate dateYearDay(int prolepticYear, int dayOfYear)
Obtains a local date in Julian 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 Julian local date, not null
- Throws:
DateTimeException- if unable to create the date
-
dateEpochDay
public JulianDate dateEpochDay(long epochDay)
Obtains a local date in the Julian calendar system from the epoch-day.- Specified by:
dateEpochDayin interfaceChronology- Parameters:
epochDay- the epoch day- Returns:
- the Julian local date, not null
- Throws:
DateTimeException- if unable to create the date
-
dateNow
public JulianDate dateNow()
Obtains the current Julian 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 Julian local date using the system clock and default time-zone, not null
- Throws:
DateTimeException- if unable to create the date
-
dateNow
public JulianDate dateNow(ZoneId zone)
Obtains the current Julian 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 Julian local date using the system clock, not null
- Throws:
DateTimeException- if unable to create the date
-
dateNow
public JulianDate dateNow(Clock clock)
Obtains the current Julian 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 Julian local date, not null
- Throws:
DateTimeException- if unable to create the date
-
date
public JulianDate date(TemporalAccessor temporal)
Obtains a Julian local date from another date-time object.- Specified by:
datein interfaceChronology- Parameters:
temporal- the date-time object to convert, not null- Returns:
- the Julian local date, not null
- Throws:
DateTimeException- if unable to create the date
-
localDateTime
public ChronoLocalDateTime<JulianDate> localDateTime(TemporalAccessor temporal)
Obtains a Julian local date-time from another date-time object.- Specified by:
localDateTimein interfaceChronology- Parameters:
temporal- the date-time object to convert, not null- Returns:
- the Julian local date-time, not null
- Throws:
DateTimeException- if unable to create the date-time
-
zonedDateTime
public ChronoZonedDateTime<JulianDate> zonedDateTime(TemporalAccessor temporal)
Obtains a Julian zoned date-time from another date-time object.- Specified by:
zonedDateTimein interfaceChronology- Parameters:
temporal- the date-time object to convert, not null- Returns:
- the Julian zoned date-time, not null
- Throws:
DateTimeException- if unable to create the date-time
-
zonedDateTime
public ChronoZonedDateTime<JulianDate> zonedDateTime(Instant instant, ZoneId zone)
Obtains a Julian 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 Julian 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 Julian proleptic-year is leap if the remainder after division by four equals zero. This method does not validate the year passed in, and only has a well-defined result for years in the supported range.
- 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
public int prolepticYear(Era era, int yearOfEra)
- Specified by:
prolepticYearin interfaceChronology
-
eraOf
public JulianEra eraOf(int eraValue)
- Specified by:
eraOfin interfaceChronology
-
eras
public List<Era> eras()
- Specified by:
erasin interfaceChronology
-
range
public ValueRange range(ChronoField field)
- Specified by:
rangein interfaceChronology
-
resolveDate
public JulianDate resolveDate(Map<TemporalField,Long> fieldValues, ResolverStyle resolverStyle)
- Specified by:
resolveDatein interfaceChronology- Overrides:
resolveDatein classAbstractChronology
-
-