U - generic type of time unitsT - generic type of time context compatible to TimePoint)public final class TimeAxis<U,T extends TimePoint<U,T>> extends Chronology<T> implements Comparator<U>, 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(U unit1,
U unit2)
Compares time units by ascending precision
(that is descending length).
|
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.
|
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 |
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.
|
createFrom, createFrom, createFrom, getCalendarSystem, getChronoType, getExtensions, 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 int compare(U unit1, U unit2)
Compares time units by ascending precision (that is descending length).
compare in interface Comparator<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 T getMinimum()
Yields the minimum of this time axis.
public T getMaximum()
Yields the maximum of this time axis.
public 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 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–2015. All rights reserved.