|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.time.i18n.HistoricDate
public final class HistoricDate
A date in the Historic calendar system.
HistoricDate is an immutable class that represents a date in the Historic calendar system.
The rules of the calendar system are described in HistoricChronology
.
The date has a precision of one day and a range within the era from
year 1 to year 999,999,999 (inclusive).
This class is immutable and thread-safe.
Field Summary | |
---|---|
static int |
MAX_YEAR
The maximum valid year of era. |
static LocalDate |
STANDARD_CUTOVER
The standard cutover date between the Julian and Gregorian calendar system of 1582-10-15. |
Method Summary | ||
---|---|---|
int |
compareTo(HistoricDate otherDate)
Compares this date to the specified date. |
|
boolean |
equals(java.lang.Object otherDate)
Checks is this date is equal to the specified date. |
|
|
get(CalendricalRule<T> ruleToDerive)
Gets the value of the specified calendrical rule. |
|
HistoricChronology |
getChronology()
Gets the chronology that this date uses, which is the historic calendar system. |
|
int |
getDayOfMonth()
Gets the historic day-of-month value. |
|
DayOfWeek |
getDayOfWeek()
Gets the historic day-of-week. |
|
int |
getDayOfYear()
Gets the historic day-of-year value. |
|
HistoricEra |
getEra()
Gets the historic era. |
|
MonthOfYear |
getMonthOfYear()
Gets the historic month-of-year value. |
|
int |
getYear()
Gets the historic year value, which can be negative. |
|
int |
getYearOfEra()
Gets the historic year-of-era value. |
|
int |
hashCode()
A hash code for this date. |
|
boolean |
isAfter(HistoricDate otherDate)
Checks is this date is after the specified date. |
|
boolean |
isBefore(HistoricDate otherDate)
Checks is this date is before the specified date. |
|
boolean |
isLeapYear()
Checks if the date represented is a leap year. |
|
static HistoricDate |
of(Calendrical calendrical)
Obtains an instance of HistoricDate from a calendrical. |
|
static HistoricDate |
of(int historicYear,
MonthOfYear monthOfYear,
int dayOfMonth)
Obtains an instance of LocalDate from a year, month and day
using the standard cutover of 1582-10-15. |
|
static HistoricDate |
of(LocalDate cutover,
int historicYear,
MonthOfYear monthOfYear,
int dayOfMonth)
Obtains an instance of LocalDate from a year, month and day
specifying the cutover date to use. |
|
HistoricDate |
plusDays(int days)
Returns a copy of this date with the specified number of days added. |
|
HistoricDate |
plusMonths(int months)
Returns a copy of this date with the specified number of months added. |
|
HistoricDate |
plusYears(int years)
Returns a copy of this date with the specified number of years added. |
|
static CalendricalRule<HistoricDate> |
rule()
Gets the rule for HistoricDate . |
|
LocalDate |
toLocalDate()
Converts this date to an ISO-8601 calendar system LocalDate . |
|
java.lang.String |
toString()
Outputs the date as a String , such as '1723-13-01 (Historic 2010-10-15)'. |
|
HistoricDate |
withDayOfMonth(int dayOfMonth)
Returns a copy of this date with the day-of-month value altered. |
|
HistoricDate |
withDayOfYear(int dayOfYear)
Returns a copy of this date with the day-of-year value altered. |
|
HistoricDate |
withMonthOfYear(MonthOfYear monthOfYear)
Returns a copy of this date with the month-of-year value altered. |
|
HistoricDate |
withYear(int historicYear)
Returns a copy of this date with the year value altered. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final LocalDate STANDARD_CUTOVER
public static final int MAX_YEAR
Method Detail |
---|
public static CalendricalRule<HistoricDate> rule()
HistoricDate
.
public static HistoricDate of(int historicYear, MonthOfYear monthOfYear, int dayOfMonth)
LocalDate
from a year, month and day
using the standard cutover of 1582-10-15.
The day must be valid for the year and month or an exception will be thrown.
historicYear
- the year to represent, from -(MAX_YEAR-1) to MAX_YEARmonthOfYear
- the month-of-year to represent, not nulldayOfMonth
- the day-of-month to represent, from 1 to 31
IllegalCalendarFieldValueException
- if the value of any field is out of range
InvalidCalendarFieldException
- if the day-of-month is invalid for the month-yearpublic static HistoricDate of(LocalDate cutover, int historicYear, MonthOfYear monthOfYear, int dayOfMonth)
LocalDate
from a year, month and day
specifying the cutover date to use.
The day must be valid for the year and month or an exception will be thrown.
historicYear
- the year to represent, from -(MAX_YEAR-1) to MAX_YEARmonthOfYear
- the month-of-year to represent, not nulldayOfMonth
- the day-of-month to represent, from 1 to 31
IllegalCalendarFieldValueException
- if the value of any field is out of range
InvalidCalendarFieldException
- if the day-of-month is invalid for the month-yearpublic static HistoricDate of(Calendrical calendrical)
HistoricDate
from a calendrical.
This can be used extract the date directly from any implementation
of Calendrical
, including those in other calendar systems.
calendrical
- the calendrical to extract from, not null
CalendricalException
- if the day-of-week cannot be obtainedpublic HistoricChronology getChronology()
public <T> T get(CalendricalRule<T> ruleToDerive)
This method queries the value of the specified calendrical rule.
If the value cannot be returned for the rule from this date then
null
will be returned.
get
in interface Calendrical
ruleToDerive
- the rule to derive, not null
public HistoricEra getEra()
The era provides a context for the year-of-era. This calendar system defines two eras, BCE and CE.
public int getYearOfEra()
The year-of-era is a value that matches the historic definition. Thus, both 1 AD and 1 BCE are represented as year-of-era 1.
public int getYear()
The year is value that is continuous. Thus, 1 AD is represented as year 1, and 1 BCE is represented as year 0.
public MonthOfYear getMonthOfYear()
public int getDayOfMonth()
public int getDayOfYear()
public DayOfWeek getDayOfWeek()
public boolean isLeapYear()
public HistoricDate withYear(int historicYear)
The result of setting the year may leave the day-of-month invalid. To avoid this, the day-of-month is changed to the largest valid value.
This instance is immutable and unaffected by this method call.
historicYear
- the year to represent, from MIN_YEAR to MAX_YEAR
HistoricDate
based on this date with the specified year, not null
IllegalCalendarFieldValueException
- if the year is out of rangepublic HistoricDate withMonthOfYear(MonthOfYear monthOfYear)
The result of setting the month may leave the day-of-month invalid. To avoid this, the day-of-month is changed to the largest valid value.
This instance is immutable and unaffected by this method call.
monthOfYear
- the month-of-year to represent, from 1 to 12
HistoricDate
based on this date with the specified month, not nullpublic HistoricDate withDayOfMonth(int dayOfMonth)
The specified day-of-month must be valid for the month and year.
This instance is immutable and unaffected by this method call.
dayOfMonth
- the day-of-month to represent, from 1 to 31
HistoricDate
based on this date with the specified day, not null
IllegalCalendarFieldValueException
- if the day is out of range
InvalidCalendarFieldException
- if the day-of-month is invalid for the year and monthpublic HistoricDate withDayOfYear(int dayOfYear)
This instance is immutable and unaffected by this method call.
dayOfYear
- the day-of-year to represent, from 1 to 366
HistoricDate
based on this date with the specified day, not null
IllegalCalendarFieldValueException
- if the day-of-year is out of range
InvalidCalendarFieldException
- if the day-of-year is invalid for the yearpublic HistoricDate plusYears(int years)
The result of changing the year may leave the day-of-month invalid. To avoid this, the day-of-month is changed to the largest valid value.
This instance is immutable and unaffected by this method call.
years
- the years to add, positive or negative
HistoricDate
based on this date with the specified years added, not null
IllegalCalendarFieldValueException
- if the year range is exceededpublic HistoricDate plusMonths(int months)
The result of changing the month may leave the day-of-month invalid. To avoid this, the day-of-month is changed to the largest valid value.
This instance is immutable and unaffected by this method call.
months
- the months to add, positive or negative
HistoricDate
based on this date with the specified months added, not null
IllegalCalendarFieldValueException
- if the year range is exceededpublic HistoricDate plusDays(int days)
This instance is immutable and unaffected by this method call.
days
- the days to add, positive or negative
HistoricDate
based on this date with the specified days added, not null
IllegalCalendarFieldValueException
- if the year range is exceededpublic LocalDate toLocalDate()
LocalDate
.
public int compareTo(HistoricDate otherDate)
The comparison is based on the year, month, day and cutover date.
compareTo
in interface java.lang.Comparable<HistoricDate>
otherDate
- the other date instance to compare to, not null
public boolean isAfter(HistoricDate otherDate)
The comparison is based on the year, month, day and cutover date.
otherDate
- the other date instance to compare to, not null
public boolean isBefore(HistoricDate otherDate)
The comparison is based on the year, month, day and cutover date.
otherDate
- the other date instance to compare to, not null
public boolean equals(java.lang.Object otherDate)
The comparison is based on the year, month, day and cutover date.
equals
in class java.lang.Object
otherDate
- the other date instance to compare to, null returns false
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
String
, such as '1723-13-01 (Historic 2010-10-15)'.
The output will be in the format 'yyyy-MM-dd (Historic 2010-10-15)' where 2010-10-15 is the cutover date.
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |