Class Calendrical<U,D extends Calendrical<U,D>>
- Type Parameters:
U
- generic type of time unit compatible toChronoUnit
)D
- generic type of self reference
- All Implemented Interfaces:
Serializable
,Comparable<D>
,CalendarDate
,ChronoDisplay
,Temporal<CalendarDate>
- Direct Known Subclasses:
BadiCalendar
,CopticCalendar
,EastAsianCalendar
,EthiopianCalendar
,FrenchRepublicanCalendar
,HebrewCalendar
,IndianCalendar
,JapaneseCalendar
,JucheCalendar
,JulianCalendar
,MinguoCalendar
,PersianCalendar
,PlainDate
,ThaiSolarCalendar
Abstract base class of all plain calendar date types which are convertible via their day epoch numbers.
- Author:
- Meno Hochschild
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Defines a total respective natural order.boolean
Based on the epoch day number and the calendar system.long
Counts the elapsed days since UTC epoch.int
hashCode()
Based on the epoch day number.boolean
isAfter(CalendarDate date)
Queries if this object is after given object on a timeline.boolean
isBefore(CalendarDate date)
Queries if this object is before given object on a timeline.boolean
isSimultaneous(CalendarDate date)
Queries if this object and given object have the same position on the time axis.minus(CalendarDays days)
Subtracts given calendar days from this instance.plus(CalendarDays days)
Adds given calendar days to this instance.Methods inherited from class net.time4j.engine.TimePoint
max, min, minus, minus, plus, plus, toString, until, until
Methods inherited from class net.time4j.engine.ChronoEntity
contains, get, get, getInt, getMaximum, getMinimum, getRegisteredElements, getTimezone, hasTimezone, isValid, isValid, isValid, matches, with, with, with, with
Methods inherited from interface net.time4j.engine.CalendarDate
transform, transform, transform, transform, transform, transform
Methods inherited from interface net.time4j.engine.Temporal
isAfterAll, isAfterOrEqual, isBeforeAll, isBeforeOrEqual
-
Constructor Details
-
Calendrical
public Calendrical()
-
-
Method Details
-
isBefore
Description copied from interface:Temporal
Queries if this object is before given object on a timeline.
-
isAfter
Description copied from interface:Temporal
Queries if this object is after given object on a timeline.
-
isSimultaneous
Description copied from interface:Temporal
Queries if this object and given object have the same position on the time axis.
Is equivalent to
!isAfter(temporal) && !isBefore(temporal)
. This method differs from theObject
-methodequals()
such that first the comparison type must be a temporal one and second that only temporal-only state will be considered.- Specified by:
isSimultaneous
in interfaceTemporal<U>
- Parameters:
date
- object this instance is compared to- Returns:
true
if this instance is temporally equal totemporal
elsefalse
-
compareTo
Defines a total respective natural order.
This implementation first evaluates the temporal position on the common timeline, that is the epoch day numbers. Only date objects of the same calendrical type are comparable. The order is consistent with
equals()
as long as subclasses don't define further state attributes. If objects of different calendrical type are to be compared on the timeline only applications can either use anEpochDays
-instance asComparator
or use one of theTemporal
-methodsisAfter()
,isBefore()
andisSimultaneous()
.- Specified by:
compareTo
in interfaceComparable<U>
- Specified by:
compareTo
in classTimePoint<U,D extends Calendrical<U,D>>
- Throws:
ClassCastException
- if there are different date types- See Also:
EpochDays.compare(ChronoDisplay, ChronoDisplay)
,isBefore(CalendarDate)
,isAfter(CalendarDate)
-
equals
Based on the epoch day number and the calendar system.
In other words: Two date object are equal if they have the same temporal position on the local timeline and have the same calendrical type. Subclasses which define further state attributes must override this method.
If an only temporal comparison is required then the method
isSimultaneous(CalendarDate)
is to be used.- Specified by:
equals
in classTimePoint<U,D extends Calendrical<U,D>>
- See Also:
Chronology.getChronoType()
-
hashCode
public int hashCode()Based on the epoch day number.
-
plus
Adds given calendar days to this instance.
- Parameters:
days
- calendar days to be added- Returns:
- result of addition
- Throws:
ArithmeticException
- in case of numerical overflow- Since:
- 3.4/4.3
-
minus
Subtracts given calendar days from this instance.
- Parameters:
days
- calendar days to be subtracted- Returns:
- result of subtraction
- Throws:
ArithmeticException
- in case of numerical overflow- Since:
- 3.4/4.3
-
getDaysSinceEpochUTC
public long getDaysSinceEpochUTC()Description copied from interface:CalendarDate
Counts the elapsed days since UTC epoch.
- Specified by:
getDaysSinceEpochUTC
in interfaceCalendarDate
- Returns:
- count of days relative to UTC epoch [1972-01-01]
- See Also:
EpochDays.UTC
-