java.io.Serializable
public final class PaxChronology
extends java.time.chrono.AbstractChronology
implements java.io.Serializable
This chronology defines the rules of the proleptic Pax calendar system.
This calendar system is a proposed reform calendar system, and is not in common use.
The Pax differs from the Gregorian in terms of month count and length, and the leap year rule.
Dates are aligned such that 0001-01-01 (Pax)
is 0000-12-31 (ISO)
.
This class is proleptic. It implements Pax rules to the entire time-line.
The fields are defined as follows:
6
, are 99
, or are 00
and the year is not divisible by 400.
For more information, please read the Pax Calendar Wikipedia article.
Modifier and Type | Field | Description |
---|---|---|
static PaxChronology |
INSTANCE |
Singleton instance for the Pax chronology.
|
Constructor | Description |
---|---|
PaxChronology() |
Deprecated.
Use the singleton
INSTANCE instead. |
Modifier and Type | Method | Description |
---|---|---|
PaxDate |
date(int prolepticYear,
int month,
int dayOfMonth) |
Obtains a local date in Pax calendar system from the
proleptic-year, month-of-year and day-of-month fields.
|
PaxDate |
date(java.time.chrono.Era era,
int yearOfEra,
int month,
int dayOfMonth) |
Obtains a local date in Pax calendar system from the
era, year-of-era, month-of-year and day-of-month fields.
|
PaxDate |
date(java.time.temporal.TemporalAccessor temporal) |
Obtains a Pax local date from another date-time object.
|
PaxDate |
dateEpochDay(long epochDay) |
Obtains a local date in the Pax calendar system from the epoch-day.
|
PaxDate |
dateNow() |
Obtains the current Pax local date from the system clock in the default time-zone.
|
PaxDate |
dateNow(java.time.Clock clock) |
Obtains the current Pax local date from the specified clock.
|
PaxDate |
dateNow(java.time.ZoneId zone) |
Obtains the current Pax local date from the system clock in the specified time-zone.
|
PaxDate |
dateYearDay(int prolepticYear,
int dayOfYear) |
Obtains a local date in Pax calendar system from the
proleptic-year and day-of-year fields.
|
PaxDate |
dateYearDay(java.time.chrono.Era era,
int yearOfEra,
int dayOfYear) |
Obtains a local date in Pax calendar system from the
era, year-of-era and day-of-year fields.
|
PaxEra |
eraOf(int eraValue) |
|
java.util.List<java.time.chrono.Era> |
eras() |
|
java.lang.String |
getCalendarType() |
Gets the calendar type of the underlying calendar system - 'pax'.
|
java.lang.String |
getId() |
Gets the ID of the chronology - 'Pax'.
|
boolean |
isLeapYear(long prolepticYear) |
Checks if the specified year is a leap year.
|
java.time.chrono.ChronoLocalDateTime<PaxDate> |
localDateTime(java.time.temporal.TemporalAccessor temporal) |
Obtains a Pax local date-time from another date-time object.
|
int |
prolepticYear(java.time.chrono.Era era,
int yearOfEra) |
|
java.time.temporal.ValueRange |
range(java.time.temporal.ChronoField field) |
|
PaxDate |
resolveDate(java.util.Map<java.time.temporal.TemporalField,java.lang.Long> fieldValues,
java.time.format.ResolverStyle resolverStyle) |
|
java.time.chrono.ChronoZonedDateTime<PaxDate> |
zonedDateTime(java.time.Instant instant,
java.time.ZoneId zone) |
Obtains a Pax zoned date-time in this chronology from an
Instant . |
java.time.chrono.ChronoZonedDateTime<PaxDate> |
zonedDateTime(java.time.temporal.TemporalAccessor temporal) |
Obtains a Pax zoned date-time from another date-time object.
|
compareTo, equals, hashCode, toString
public static final PaxChronology INSTANCE
@Deprecated public PaxChronology()
INSTANCE
instead.ServiceLoader
.public java.lang.String getId()
The ID uniquely identifies the Chronology
.
It can be used to lookup the Chronology
using Chronology.of(String)
.
getCalendarType()
public java.lang.String getCalendarType()
The Unicode Locale Data Markup Language (LDML) specification does not define an identifier for the Pax calendar, but were it to do so, 'pax' is highly likely to be chosen.
getId()
public PaxDate date(java.time.chrono.Era era, int yearOfEra, int month, int dayOfMonth)
era
- the Pax era, not nullyearOfEra
- the year-of-eramonth
- the month-of-yeardayOfMonth
- the day-of-monthjava.time.DateTimeException
- if unable to create the datejava.lang.ClassCastException
- if the era
is not a PaxEra
public PaxDate date(int prolepticYear, int month, int dayOfMonth)
prolepticYear
- the proleptic-yearmonth
- the month-of-yeardayOfMonth
- the day-of-monthjava.time.DateTimeException
- if unable to create the datepublic PaxDate dateYearDay(java.time.chrono.Era era, int yearOfEra, int dayOfYear)
era
- the Pax era, not nullyearOfEra
- the year-of-eradayOfYear
- the day-of-yearjava.time.DateTimeException
- if unable to create the datejava.lang.ClassCastException
- if the era
is not a PaxEra
public PaxDate dateYearDay(int prolepticYear, int dayOfYear)
prolepticYear
- the proleptic-yeardayOfYear
- the day-of-yearjava.time.DateTimeException
- if unable to create the datepublic PaxDate dateEpochDay(long epochDay)
epochDay
- the epoch dayjava.time.DateTimeException
- if unable to create the datepublic PaxDate dateNow()
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.
java.time.DateTimeException
- if unable to create the datepublic PaxDate dateNow(java.time.ZoneId 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.
zone
- the ZoneId to use, not nulljava.time.DateTimeException
- if unable to create the datepublic PaxDate dateNow(java.time.Clock 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
.
clock
- the clock to use, not nulljava.time.DateTimeException
- if unable to create the datepublic PaxDate date(java.time.temporal.TemporalAccessor temporal)
temporal
- the date-time object to convert, not nulljava.time.DateTimeException
- if unable to create the datepublic java.time.chrono.ChronoLocalDateTime<PaxDate> localDateTime(java.time.temporal.TemporalAccessor temporal)
temporal
- the date-time object to convert, not nulljava.time.DateTimeException
- if unable to create the date-timepublic java.time.chrono.ChronoZonedDateTime<PaxDate> zonedDateTime(java.time.temporal.TemporalAccessor temporal)
temporal
- the date-time object to convert, not nulljava.time.DateTimeException
- if unable to create the date-timepublic java.time.chrono.ChronoZonedDateTime<PaxDate> zonedDateTime(java.time.Instant instant, java.time.ZoneId zone)
Instant
.instant
- the instant to create the date-time from, not nullzone
- the time-zone, not nulljava.time.DateTimeException
- if the result exceeds the supported rangepublic boolean isLeapYear(long prolepticYear)
In general, a year is a leap year if the last two digits are divisible by 6 without remainder, or are 99. Years with the last two digits of 00 are also leap years, with the exception of years divisible by 400, which are not.
For example, 2012 is a leap year because the last two digits (12) are divisible by 6. 1999 is a leap year as the last two digits are both 9's (99). 1900 is a leap year as the last two digits are both 0's (00), however 2000 was not a leap year as it is divisible by 400. The year 0 is not a leap year.
prolepticYear
- the proleptic-year to check, not validated for rangepublic int prolepticYear(java.time.chrono.Era era, int yearOfEra)
public PaxEra eraOf(int eraValue)
public java.util.List<java.time.chrono.Era> eras()
public java.time.temporal.ValueRange range(java.time.temporal.ChronoField field)
public PaxDate resolveDate(java.util.Map<java.time.temporal.TemporalField,java.lang.Long> fieldValues, java.time.format.ResolverStyle resolverStyle)
resolveDate
in class java.time.chrono.AbstractChronology
Copyright © 2010–2018 ThreeTen.org. All rights reserved.