/** * Tests this time period instance for equality with an arbitrary object. * The object is considered equal if it is an instance of {@link TimePeriod} * and it has the same start and end dates. * * @param obj the other object ({@code null} permitted). * * @return A boolean. */ @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof TimePeriod)) { return false; } TimePeriod that = (TimePeriod) obj; if (!this.getStart().equals(that.getStart())) { return false; } if (!this.getEnd().equals(that.getEnd())) { return false; } return true; }
/** * Tests this time period instance for equality with an arbitrary object. * The object is considered equal if it is an instance of {@link TimePeriod} * and it has the same start and end dates. * * @param obj the other object (<code>null</code> permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof TimePeriod)) { return false; } TimePeriod that = (TimePeriod) obj; if (!this.getStart().equals(that.getStart())) { return false; } if (!this.getEnd().equals(that.getEnd())) { return false; } return true; }
public int compareTo(Object obj) { TimePeriod that = (TimePeriod) obj; long t0 = getStart().getTime(); long t1 = getEnd().getTime(); long m0 = t0 + (t1 - t0) / 2L;
long t0 = getStart().getTime(); long t1 = getEnd().getTime(); long m0 = t0 + (t1 - t0) / 2L;