MCPcopy Create free account
hub / github.com/MenoData/Time4J / between

Method between

base/src/main/java/net/time4j/Duration.java:4385–4412  ·  view source on GitHub ↗
(
            T start,
            T end
        )

Source from the content-addressed store, hash-verified

4383 //~ Methoden ------------------------------------------------------
4384
4385 @Override
4386 public <T extends TimePoint<? super IsoUnit, T>> Duration<IsoUnit> between(
4387 T start,
4388 T end
4389 ) {
4390
4391 T t1 = start;
4392 T t2 = end;
4393 boolean negative = false;
4394
4395 if (start.compareTo(end) > 0) {
4396 t1 = end;
4397 t2 = start;
4398 negative = true;
4399 }
4400
4401 int o1 = this.getOffset(t1);
4402 int o2 = this.getOffset(t2);
4403 t2 = t2.plus(o1 - o2, SECONDS);
4404 Duration<IsoUnit> duration = this.metric.between(t1, t2);
4405
4406 if (negative) {
4407 duration = duration.inverse();
4408 }
4409
4410 return duration;
4411
4412 }
4413
4414 private int getOffset(ChronoEntity<?> entity) {
4415

Callers

nothing calls this directly

Calls 5

getOffsetMethod · 0.95
betweenMethod · 0.65
compareToMethod · 0.45
plusMethod · 0.45
inverseMethod · 0.45

Tested by

no test coverage detected