@Override public Temporal apply(Temporal arg1, Temporal arg2, int flags) { if (arg1 == null) { return arg2; } if (arg2 == null) { return arg1; } if (arg1 instanceof Duration && arg2 instanceof Duration) { return ((Duration) arg1).add((Duration) arg2); } else if (arg1 instanceof Time && arg2 instanceof Duration) { return ((Time) arg1).add((Duration) arg2); } else if (arg1 instanceof Range && arg2 instanceof Duration) { return ((Range) arg1).add((Duration) arg2); } else { throw new UnsupportedOperationException("PLUS not implemented for arg1=" + arg1.getClass() + ", arg2=" + arg2.getClass()); } } },
((PartialTime) start).withStandardFields(); Time end = start.add(d); if (granularity != null) { end = end.subtract(granularity);
private static Range getIntersectedRange(CompositePartialTime cpt, Range r, Duration d) { Time beginTime = r.beginTime(); Time endTime = r.endTime(); if (beginTime != TIME_UNKNOWN && endTime != TIME_UNKNOWN) { Time t1 = cpt.intersect(r.beginTime()); if (t1 instanceof PartialTime) { ((PartialTime) t1).withStandardFields(); } Time t2 = cpt.intersect(r.endTime()); if (t2 instanceof PartialTime) { ((PartialTime) t2).withStandardFields(); } return new Range(t1, t2, d); } else if (beginTime != TIME_UNKNOWN && endTime == TIME_UNKNOWN) { Time t1 = cpt.intersect(r.beginTime()); if (t1 instanceof PartialTime) { ((PartialTime) t1).withStandardFields(); } Time t2 = t1.add(d); if (t2 instanceof PartialTime) { ((PartialTime) t2).withStandardFields(); } return new Range(t1, t2, d); } else { throw new RuntimeException("Unsupported range: " + r); } }
private static Range getIntersectedRange(CompositePartialTime cpt, Range r, Duration d) { Time beginTime = r.beginTime(); Time endTime = r.endTime(); if (beginTime != TIME_UNKNOWN && endTime != TIME_UNKNOWN) { Time t1 = cpt.intersect(r.beginTime()); if (t1 instanceof PartialTime) { ((PartialTime) t1).withStandardFields(); } Time t2 = cpt.intersect(r.endTime()); if (t2 instanceof PartialTime) { ((PartialTime) t2).withStandardFields(); } return new Range(t1, t2, d); } else if (beginTime != TIME_UNKNOWN && endTime == TIME_UNKNOWN) { Time t1 = cpt.intersect(r.beginTime()); if (t1 instanceof PartialTime) { ((PartialTime) t1).withStandardFields(); } Time t2 = t1.add(d); if (t2 instanceof PartialTime) { ((PartialTime) t2).withStandardFields(); } return new Range(t1, t2, d); } else { throw new RuntimeException("Unsupported range: " + r); } }
public Temporal apply(Temporal arg1, Temporal arg2, int flags) { if (arg1 == null) { return arg2; } if (arg2 == null) { return arg1; } if (arg1 instanceof Duration && arg2 instanceof Duration) { return ((Duration) arg1).add((Duration) arg2); } else if (arg1 instanceof Time && arg2 instanceof Duration) { return ((Time) arg1).add((Duration) arg2); } else if (arg1 instanceof Range && arg2 instanceof Duration) { return ((Range) arg1).add((Duration) arg2); } else { throw new UnsupportedOperationException("PLUS not implemented for arg1=" + arg1.getClass() + ", arg2=" + arg2.getClass()); } } },
@Override public Temporal apply(Temporal arg1, Temporal arg2, int flags) { if (arg1 == null) { return arg2; } if (arg2 == null) { return arg1; } if (arg1 instanceof Duration && arg2 instanceof Duration) { return ((Duration) arg1).add((Duration) arg2); } else if (arg1 instanceof Time && arg2 instanceof Duration) { return ((Time) arg1).add((Duration) arg2); } else if (arg1 instanceof Range && arg2 instanceof Duration) { return ((Range) arg1).add((Duration) arg2); } else { throw new UnsupportedOperationException("PLUS not implemented for arg1=" + arg1.getClass() + ", arg2=" + arg2.getClass()); } } },
public Temporal apply(Temporal arg1, Temporal arg2, int flags) { if (arg1 == null) { return arg2; } if (arg2 == null) { return arg1; } if (arg1 instanceof Duration && arg2 instanceof Duration) { return ((Duration) arg1).add((Duration) arg2); } else if (arg1 instanceof Time && arg2 instanceof Duration) { return ((Time) arg1).add((Duration) arg2); } else if (arg1 instanceof Range && arg2 instanceof Duration) { return ((Range) arg1).add((Duration) arg2); } else { throw new UnsupportedOperationException("PLUS not implemented for arg1=" + arg1.getClass() + ", arg2=" + arg2.getClass()); } } },
public Time mid() { if (duration != null && begin != null) { Time b = begin.getRange(RANGE_FLAGS_PAD_SPECIFIED,duration.getGranularity()).begin(); return b.add(duration.divideBy(2)); } else if (duration != null && end != null) { return end.subtract(duration.divideBy(2)); } else if (begin != null && end != null) { // TODO: .... } else if (begin != null) { return begin; } else if (end != null) { return end; } return null; }
public Time mid() { if (duration != null && begin != null) { return begin.add(duration.divideBy(2)); } else if (duration != null && end != null) { return end.subtract(duration.divideBy(2)); } else if (begin != null && end != null) { // TODO: .... } else if (begin != null) { return begin; } else if (end != null) { return end; } return null; }
public Time subtract(Duration offset) { return add(offset.multiplyBy(-1)); }
public Time subtract(Duration offset) { return add(offset.multiplyBy(-1)); }
public Time offset(Duration offset) { return add(offset); }
public Time subtract(Duration offset) { return add(offset.multiplyBy(-1)); }
public Time mid() { if (duration != null && begin != null) { Time b = begin.getRange(RANGE_FLAGS_PAD_SPECIFIED,duration.getGranularity()).begin(); return b.add(duration.divideBy(2)); } else if (duration != null && end != null) { return end.subtract(duration.divideBy(2)); } else if (begin != null && end != null) { // TODO: .... } else if (begin != null) { return begin; } else if (end != null) { return end; } return null; }
public Time offset(Duration offset, int flags) { Time res = add(offset); if ((flags & RELATIVE_OFFSET_INEXACT) != 0) { // Mark as uncertain anything not as granular as the granularity of the offset res.uncertaintyGranularity = offset.getGranularity(); return res; } else { return res; } }
public Time offset(Duration offset, int flags) { Time res = add(offset); if ((flags & RELATIVE_OFFSET_INEXACT) != 0) { // Mark as uncertain anything not as granular as the granularity of the offset res.uncertaintyGranularity = offset.getGranularity(); return res; } else { return res; } }
public Time mid() { if (duration != null && begin != null) { Time b = begin.getRange(RANGE_FLAGS_PAD_SPECIFIED,duration.getGranularity()).begin(); return b.add(duration.divideBy(2)); } else if (duration != null && end != null) { return end.subtract(duration.divideBy(2)); } else if (begin != null && end != null) { // TODO: .... } else if (begin != null) { return begin; } else if (end != null) { return end; } return null; }
public Time subtract(Duration offset) { return add(offset.multiplyBy(-1)); }
public Time offset(Duration offset, int flags) { Time res = add(offset); if ((flags & RELATIVE_OFFSET_INEXACT) != 0) { // Mark as uncertain anything not as granular as the granularity of the offset res.uncertaintyGranularity = offset.getGranularity(); return res; } else { return res; } }