added before/after/plus to TimePoint/AbstractTimePoint

This commit is contained in:
Axel Uhl committed 2012-07-23 00:40:37 +02:00
1 parent 5d04b737cb
commit b03b4b0e41
2 files changed
+21

No files matched your search

@@ -7,4 +7,10 @@ public interface TimePoint extends Comparable<TimePoint>, Serializable {
long asMillis();
Date asDate();
TimePoint plus(long milliseconds);
boolean after(TimePoint other);
boolean before(TimePoint other);
}
@@ -37,6 +37,21 @@ public abstract class AbstractTimePoint implements TimePoint {
return result;
}
@Override
public TimePoint plus(long milliseconds) {
return new MillisecondsTimePoint(asMillis()+milliseconds);
}
@Override
public boolean after(TimePoint other) {
return this.compareTo(other) > 0;
}
@Override
public boolean before(TimePoint other) {
return this.compareTo(other) < 0;
}
@Override
public int hashCode() {
return (int) (asMillis() & Integer.MAX_VALUE);