U - generic type of time unitsT - generic type of time context compatible to TimePointpublic final class TimeAxis<U,T extends TimePoint<U,T>> extends Chronology<T> implements TimeLine<T>
A time axis is a dynamic view on a chronology where a system of registered time units is used to define a time arithmetic for any time points belonging to this time axis respective chronology.
| Modifier and Type | Class and Description |
|---|---|
static class |
TimeAxis.Builder<U,T extends TimePoint<U,T>>
Creates a builder for a new time axis respective chronology
and will only be used during loading a class of type
TimePoint (T) in a static initializer. |
| Modifier and Type | Method and Description |
|---|---|
int |
compare(T first,
T second)
Compares points in time by their temporal position on the timeline.
|
T |
createFrom(ChronoEntity<?> entity,
AttributeQuery attributes,
boolean preparsing)
Deprecated.
|
T |
createFrom(ChronoEntity<?> entity,
AttributeQuery attributes,
boolean lenient,
boolean preparsing)
Creates a new entity of type T based on given chronological data.
|
ChronoElement<T> |
element()
Yields this time axis as chronological self-referencing
element.
|
U |
getBaseUnit(ChronoElement<?> element)
Returns the base unit of given element if available.
|
CalendarSystem<T> |
getCalendarSystem()
Returns the associated calendar system if available.
|
CalendarSystem<T> |
getCalendarSystem(String variant)
Returns the calendar system for given calendar variant if available.
|
double |
getLength(U unit)
Returns the length of given time unit in seconds as it is
usual or estimated on this time axis.
|
T |
getMaximum()
Yields the maximum of this time axis.
|
T |
getMinimum()
Yields the minimum of this time axis.
|
Set<U> |
getRegisteredUnits()
Returns all registered time units.
|
Class<U> |
getUnitType()
Returns the type of supported time units.
|
boolean |
hasBaseUnit(ChronoElement<?> element)
Queries if given element has a base unit.
|
boolean |
hasCalendarSystem()
Queries if this chronology has a calendar system.
|
boolean |
isCalendrical()
Determines if this timeline is calendrical or not.
|
boolean |
isConvertible(U unit1,
U unit2)
Queries if given time units are convertible.
|
boolean |
isRegistered(U unit)
Queries if given time unit is registered.
|
boolean |
isSupported(U unit)
Queries if given time unit is supported.
|
T |
stepBackwards(T timepoint)
Move given point in time backwards by one step.
|
T |
stepForward(T timepoint)
Move given point in time forward by one step.
|
Comparator<? super U> |
unitComparator()
Compares time units by ascending precision (that is descending length).
|
createFrom, createFrom, getChronoType, getDefaultPivotYear, getDefaultStartOfDay, getExtensions, getFormatPattern, getRegisteredElements, isRegistered, isSupported, lookup, preformat, preparserequals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcomparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLongpublic Class<U> getUnitType()
Returns the type of supported time units.
public Set<U> getRegisteredUnits()
Returns all registered time units.
public boolean isRegistered(U unit)
Queries if given time unit is registered.
unit - time unit (optional)true if registered else falsepublic boolean isSupported(U unit)
Queries if given time unit is supported.
A time unit is supported if it is either registered or if it defines a suitable rule.
unit - time unit (optional)true if supported else falseBasicUnit.derive(Chronology)public double getLength(U unit)
Returns the length of given time unit in seconds as it is usual or estimated on this time axis.
Example: In ISO-systems the year has 365.2425 * 86400
seconds by default (mean average), in a julian calender
365.25 * 86400 seconds however. Daylight-saving-transitions
or UTC-leapseconds are not counted here.
Note: If given time unit is not registered then Time4J tries
to interprete the unit as ChronoUnit. If this fails, too,
then the length is not calculatable.
unit - time unitDouble.NaN if not calculatableChronoUnitpublic boolean isConvertible(U unit1, U unit2)
Queries if given time units are convertible.
Convertibility means that there exists a fixed integer factor
for conversion between the units. Examples for convertible units
are weeks/days (factor 7) or years/months (factor 12) in ISO-systems.
Otherwise minutes and seconds will only be convertible with factor
60 if there is no UTC-context with possible leap seconds.
If two time units are convertible then the length of a time unit
(getLength()) can be used to convert time units by applying
the rounded quotient of lengths of units.
unit1 - first time unitunit2 - second time unittrue if convertible else falsegetLength(U)public boolean hasBaseUnit(ChronoElement<?> element)
Queries if given element has a base unit.
element - chronological element (optional)true if given element has a base unit else falsegetBaseUnit(ChronoElement)public U getBaseUnit(ChronoElement<?> element)
Returns the base unit of given element if available.
Only registred elements can have a base unit unless the element
is a BasicElement and refers another registered element with
a base unit.
element - chronological elementChronoException - if there is no base unithasBaseUnit(ChronoElement),
BasicElement.getParent()public Comparator<? super U> unitComparator()
Compares time units by ascending precision (that is descending length).
Note: Before release v4.21, the time axis implemented Comparator<U>, not Comparator<T>.
This new method serves as the replacement for the old comparator method.
compare(TimePoint, TimePoint)public int compare(T first, T second)
Compares points in time by their temporal position on the timeline.
public T getMinimum()
Yields the minimum of this time axis.
public T getMaximum()
Yields the maximum of this time axis.
public boolean isCalendrical()
TimeLineisCalendrical in interface TimeLine<T extends TimePoint<U,T>>CalendarDatepublic boolean hasCalendarSystem()
ChronologyQueries if this chronology has a calendar system.
hasCalendarSystem in class Chronology<T extends TimePoint<U,T>>true if this chronology has a calendar system else falseChronology.getCalendarSystem()public CalendarSystem<T> getCalendarSystem()
ChronologyReturns the associated calendar system if available.
getCalendarSystem in class Chronology<T extends TimePoint<U,T>>nullChronology.hasCalendarSystem()public CalendarSystem<T> getCalendarSystem(String variant)
ChronologyReturns the calendar system for given calendar variant if available.
getCalendarSystem in class Chronology<T extends TimePoint<U,T>>variant - name of calendar variantnullCalendarVariant.getVariant()@Deprecated public T createFrom(ChronoEntity<?> entity, AttributeQuery attributes, boolean preparsing)
ChronoMergerCreates a new entity of type T based on given chronological data.
Typically the method will query the given entity with
different priorities for elements which can compose a new chronological
entity (per group). For example a calendar date can be composed either
by epoch days or the group (year)-(month)-(day-of-month) or the group
(year)-(day-of-year) etc.
A text parser will call this method after having resolved a text
into single chronological elements and values. Implementations should
always validate the parsed values. In case of error, they are free to
either throw an IllegalArgumentException or to generate
and to save an error message by mean of the expression
entity.with(ValidationElement.ERROR_MESSAGE, message.
createFrom in interface ChronoMerger<T extends TimePoint<U,T>>createFrom in class Chronology<T extends TimePoint<U,T>>entity - any chronological entity like parsed
elements with their valuesattributes - configuration attributes given by parserpreparsing - preparsing phase active?null if given data are insufficientValidationElement.ERROR_MESSAGEpublic T createFrom(ChronoEntity<?> entity, AttributeQuery attributes, boolean lenient, boolean preparsing)
ChronoMergerCreates a new entity of type T based on given chronological data.
Typically the method will query the given entity with
different priorities for elements which can compose a new chronological
entity (per group). For example a calendar date can be composed either
by epoch days or the group (year)-(month)-(day-of-month) or the group
(year)-(day-of-year) etc.
A text parser will call this method after having resolved a text
into single chronological elements and values. Implementations should
always validate the parsed values. In case of error, they are free to
either throw an IllegalArgumentException or to generate
and to save an error message by mean of the expression
entity.with(ValidationElement.ERROR_MESSAGE, message.
createFrom in interface ChronoMerger<T extends TimePoint<U,T>>createFrom in class Chronology<T extends TimePoint<U,T>>entity - any chronological entity like parsed
elements with their valuesattributes - configuration attributes given by parserlenient - controls the leniency how to interprete invalid valuespreparsing - preparsing phase active?null if given data are insufficientValidationElement.ERROR_MESSAGEpublic ChronoElement<T> element()
Yields this time axis as chronological self-referencing element.
public T stepForward(T timepoint)
TimeLineMove given point in time forward by one step.
Copyright © 2014–2017. All rights reserved.