U - generic type of time unit (ChronoUnit)P - generic type of duration resultpublic abstract class AbstractMetric<U extends ChronoUnit,P extends AbstractDuration<U>> extends Object implements TimeMetric<U,P>, Comparator<U>
Represents a metric suitable for the default algorithm of Time4J.
If the starting time point is after the end time point then a
duration computed with this metric will be negative. In this case
the metric defined here will first toggle the time points to be
compared and then compare all elements in the order of ascending
precision. Elements which differ less than a full unit will cause
an amount of 0 in related duration item. Convertible units
will be consolidated in one step. Finally the representation of
the duration will be normalized such that small units will be
converted to larger units if possible.
AbstractDuration| Modifier and Type | Method and Description |
|---|---|
<T extends TimePoint<? super U,T>> |
between(T start,
T end)
Computes the temporal distance between two time points.
|
int |
compare(U u1,
U u2)
Compares time units by their length in descending order.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcomparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLongpublic int compare(U u1, U u2)
Compares time units by their length in descending order.
compare in interface Comparator<U extends ChronoUnit>u1 - first time unitu2 - second time unitpublic <T extends TimePoint<? super U,T>> P between(T start, T end)
TimeMetricComputes the temporal distance between two time points.
Important note: This method might not work in Java 6 under some circumstances.
In case of any problem users can use the equivalent method until() defined in the class
TimePoint.
between in interface TimeMetric<U extends ChronoUnit,P extends AbstractDuration<U>>T - generic type of time pointstart - first time pointend - second time pointstart is after endTimePoint.until(TimePoint, TimeMetric)Copyright © 2014–2015. All rights reserved.