public DefaultPeriod(Instant begining, Instant ending) { if (begining.relativePosition(ending).equals(RelativePosition.BEFORE)) { this.begining = begining; this.ending = ending; } /*if (((DefaultInstant) begining).getPosition().getDate().before(((DefaultInstant) ending).getPosition().getDate())) { this.begining = begining; this.ending = ending; } */ else { throw new IllegalArgumentException( "The temporal position of the beginning of the period must be less than (i.e. earlier than) the temporal position of the end of the period"); } }
if (this.relativePosition(other).equals(RelativePosition.BEFORE) || this.relativePosition(other).equals(RelativePosition.AFTER)) { if (this instanceof Instant && other instanceof Instant) { diff = if (this.relativePosition(other).equals(RelativePosition.BEGINS) || this.relativePosition(other).equals(RelativePosition.BEGUN_BY) || this.relativePosition(other).equals(RelativePosition.CONTAINS) || this.relativePosition(other).equals(RelativePosition.DURING) || this.relativePosition(other).equals(RelativePosition.ENDED_BY) || this.relativePosition(other).equals(RelativePosition.ENDS) || this.relativePosition(other).equals(RelativePosition.EQUALS) || this.relativePosition(other).equals(RelativePosition.MEETS) || this.relativePosition(other).equals(RelativePosition.MET_BY) || this.relativePosition(other).equals(RelativePosition.OVERLAPPED_BY) || this.relativePosition(other).equals(RelativePosition.OVERLAPS)) { diff = 0L;
/** Test of relativePosition method, of class DefaultTemporalPrimitive. */ @Test public void testRelativePosition() { TemporalPrimitive other; // relative position between Instant objects cal.set(2000, 0, 1); Position position = new DefaultPosition(cal.getTime()); other = new DefaultInstant(position); RelativePosition result = temporalPrimitive1.relativePosition(other); assertFalse(temporalPrimitive2.relativePosition(other).equals(result)); // relative position between Instant and Period Instant instant1 = new DefaultInstant(new DefaultPosition(cal.getTime())); Instant instant2 = (DefaultInstant) temporalPrimitive2; other = new DefaultPeriod(instant1, instant2); result = temporalPrimitive1.relativePosition(other); assertFalse(temporalPrimitive2.relativePosition(other).equals(result)); // relative position between Period onbjects temporalPrimitive1 = new DefaultPeriod(new DefaultInstant(position1), instant1); cal.set(2200, 9, 1); temporalPrimitive2 = new DefaultPeriod(instant2, new DefaultInstant(new DefaultPosition(cal.getTime()))); result = temporalPrimitive1.relativePosition(other); assertFalse(temporalPrimitive2.relativePosition(other).equals(result)); } }
public DefaultPeriod(Instant begining, Instant ending) { if (begining.relativePosition(ending).equals(RelativePosition.BEFORE)) { this.begining = begining; this.ending = ending; } /*if (((DefaultInstant) begining).getPosition().getDate().before(((DefaultInstant) ending).getPosition().getDate())) { this.begining = begining; this.ending = ending; } */else { throw new IllegalArgumentException("The temporal position of the beginning of the period must be less than (i.e. earlier than) the temporal position of the end of the period"); } }
public DefaultPeriod(Instant begining, Instant ending) { if (begining.relativePosition(ending).equals(RelativePosition.BEFORE)) { this.begining = begining; this.ending = ending; } /*if (((DefaultInstant) begining).getPosition().getDate().before(((DefaultInstant) ending).getPosition().getDate())) { this.begining = begining; this.ending = ending; } */else { throw new IllegalArgumentException("The temporal position of the beginning of the period must be less than (i.e. earlier than) the temporal position of the end of the period"); } }
if (this.relativePosition(other).equals(RelativePosition.BEFORE) || this.relativePosition(other).equals(RelativePosition.AFTER)) { if (this instanceof Instant && other instanceof Instant) { diff = Math.min(Math.abs(((Instant) other).getPosition().getDate().getTime() - ((Instant) this).getPosition().getDate().getTime()), if (this.relativePosition(other).equals(RelativePosition.BEGINS) || this.relativePosition(other).equals(RelativePosition.BEGUN_BY) || this.relativePosition(other).equals(RelativePosition.CONTAINS) || this.relativePosition(other).equals(RelativePosition.DURING) || this.relativePosition(other).equals(RelativePosition.ENDED_BY) || this.relativePosition(other).equals(RelativePosition.ENDS) || this.relativePosition(other).equals(RelativePosition.EQUALS) || this.relativePosition(other).equals(RelativePosition.MEETS) || this.relativePosition(other).equals(RelativePosition.MET_BY) || this.relativePosition(other).equals(RelativePosition.OVERLAPPED_BY) || this.relativePosition(other).equals(RelativePosition.OVERLAPS)) {
if (this.relativePosition(other).equals(RelativePosition.BEFORE) || this.relativePosition(other).equals(RelativePosition.AFTER)) { if (this instanceof Instant && other instanceof Instant) { diff = Math.min(Math.abs(((Instant) other).getPosition().getDate().getTime() - ((Instant) this).getPosition().getDate().getTime()), if (this.relativePosition(other).equals(RelativePosition.BEGINS) || this.relativePosition(other).equals(RelativePosition.BEGUN_BY) || this.relativePosition(other).equals(RelativePosition.CONTAINS) || this.relativePosition(other).equals(RelativePosition.DURING) || this.relativePosition(other).equals(RelativePosition.ENDED_BY) || this.relativePosition(other).equals(RelativePosition.ENDS) || this.relativePosition(other).equals(RelativePosition.EQUALS) || this.relativePosition(other).equals(RelativePosition.MEETS) || this.relativePosition(other).equals(RelativePosition.MET_BY) || this.relativePosition(other).equals(RelativePosition.OVERLAPPED_BY) || this.relativePosition(other).equals(RelativePosition.OVERLAPS)) {