T
 generic type of time context compatible to TimePoint
public interface UnitRule<T>
Represents a rule for the addition or subtraction associated with a time unit.
A unit rule will usually be registered together with an unit for a
TimeAxis
, during loading of the concrete TimePoint
class.
For every time axis and every time unit there is exactly one rule
instance. Implementations must be always immutable.
Modifier and Type  Method and Description 

T 
addTo(T timepoint,
long amount)
Adds given amount to a time point in the context of an
associated time unit.

long 
between(T start,
T end)
Queries how many units are between given time points.

T addTo(T timepoint, long amount)
Adds given amount to a time point in the context of an associated time unit.
This method is called by the plus()
 and
minus()
methods in the class TimePoint
. If not
specified otherwise then a possible range overflow will be
resolved such that the last valid time point is choosen. For
example the addition of one month to date of 31th of may will
yield June, 30th.
timepoint
 time pointamount
 count of units to be added toIllegalArgumentException
 if boundary constraints are violatedArithmeticException
 in case of numerical overflowTimePoint.plus(long, U)
,
TimePoint.minus(long, U)
long between(T start, T end)
Queries how many units are between given time points.
This method is called by TimePoint.until(T, U)
. The
expression start.until(end, unit)
corresponds to
ruleForUnit.between(start, end)
. Only full units will
be counted. A possible remainder of subtraction will always
be truncated.
start
 start time pointend
 end time pointend
is before
start
)ArithmeticException
 in case of numerical overflowTimePoint.until(T, U)
Copyright © 2014–2020. All rights reserved.