U - generic type of time unit compatible to ChronoUnit)D - generic type of self referencepublic abstract class Calendrical<U,D extends Calendrical<U,D>> extends TimePoint<U,D> implements CalendarDate
Abstract base class of all plain calendar date types which are convertible via their day epoch numbers.
| Constructor and Description |
|---|
Calendrical() |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(D date)
Defines a total respective natural order.
|
boolean |
equals(Object obj)
Based on the epoch day number and the calendar system.
|
long |
getDaysSinceEpochUTC()
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.
|
D |
minus(CalendarDays days)
Subtracts given calendar days from this instance.
|
D |
plus(CalendarDays days)
Adds given calendar days to this instance.
|
<T extends Calendrical<?,T>> |
transform(Class<T> target)
Converts this calendar date to the given target type based on
the count of days relative to UTC epoch [1972-01-01].
|
<T extends CalendarVariant<T>> |
transform(Class<T> target,
String variant)
Converts this calendar date to the given target type based on
the count of days relative to UTC epoch [1972-01-01].
|
<T extends CalendarVariant<T>> |
transform(Class<T> target,
VariantSource variantSource)
Converts this calendar date to the given target type based on
the count of days relative to UTC epoch [1972-01-01].
|
max, min, minus, minus, plus, plus, toString, until, untilcontains, get, get, getInt, getMaximum, getMinimum, getRegisteredElements, getTimezone, hasTimezone, isValid, isValid, isValid, matches, with, with, with, withpublic <T extends Calendrical<?,T>> T transform(Class<T> target)
Converts this calendar date to the given target type based on the count of days relative to UTC epoch [1972-01-01].
The conversion occurs on the local timeline at noon. This reference time ensures that all date types remain convertible even if a calendar system defines dates not starting at midnight.
T - generic target date typetarget - chronological type this date shall be converted toIllegalArgumentException - if the target class does not
have any chronologyArithmeticException - in case of numerical overflowpublic <T extends CalendarVariant<T>> T transform(Class<T> target, String variant)
Converts this calendar date to the given target type based on the count of days relative to UTC epoch [1972-01-01].
The conversion occurs on the local timeline at noon. This reference time ensures that all date types remain convertible even if a calendar system defines dates not starting at midnight.
T - generic target date typetarget - chronological type this date shall be converted tovariant - desired calendar variantIllegalArgumentException - if the target class does not have any chronologyArithmeticException - in case of numerical overflowpublic <T extends CalendarVariant<T>> T transform(Class<T> target, VariantSource variantSource)
Converts this calendar date to the given target type based on the count of days relative to UTC epoch [1972-01-01].
The conversion occurs on the local timeline at noon. This reference time ensures that all date types remain convertible even if a calendar system defines dates not starting at midnight.
T - generic target date typetarget - chronological type this date shall be converted tovariantSource - source of desired calendar variantChronoException - if given variant is not recognizedIllegalArgumentException - if the target class does not have any chronologyArithmeticException - in case of numerical overflowpublic boolean isBefore(CalendarDate date)
TemporalQueries if this object is before given object on a timeline.
isBefore in interface Temporal<CalendarDate>date - object this instance is compared totrue if this instance is temporally before
temporal else falsepublic boolean isAfter(CalendarDate date)
TemporalQueries if this object is after given object on a timeline.
isAfter in interface Temporal<CalendarDate>date - object this instance is compared totrue if this instance is temporally after
temporal else falsepublic boolean isSimultaneous(CalendarDate date)
TemporalQueries 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 the Object-method equals()
such that first the comparison type must be a temporal one and second
that only temporal-only state will be considered.
isSimultaneous in interface Temporal<CalendarDate>date - object this instance is compared totrue if this instance is temporally equal
to temporal else falsepublic int compareTo(D date)
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 an
EpochDays-instance as Comparator or use one of
the Temporal-methods isAfter(), isBefore()
and isSimultaneous().
compareTo in interface Comparable<D extends Calendrical<U,D>>compareTo in class TimePoint<U,D extends Calendrical<U,D>>ClassCastException - if there are different date typesEpochDays.compare(ChronoDisplay, ChronoDisplay),
Calendrical.isBefore(CalendarDate),
Calendrical.isAfter(CalendarDate)public boolean equals(Object obj)
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
Calendrical.isSimultaneous(CalendarDate) is to be used.
equals in class TimePoint<U,D extends Calendrical<U,D>>Chronology.getChronoType()public int hashCode()
Based on the epoch day number.
public D plus(CalendarDays days)
Adds given calendar days to this instance.
days - calendar days to be addedArithmeticException - in case of numerical overflowpublic D minus(CalendarDays days)
Subtracts given calendar days from this instance.
days - calendar days to be subtractedArithmeticException - in case of numerical overflowpublic long getDaysSinceEpochUTC()
CalendarDateCounts the elapsed days since UTC epoch.
getDaysSinceEpochUTC in interface CalendarDateEpochDays.UTCCopyright © 2014–2016. All rights reserved.