* Notice that the adjusted timestamp value could be negative e.g. for events
* that occurred before t0 wrt the reference clock.
*/
-public class TmfTimestamp implements Cloneable {
+public class TmfTimestamp implements Cloneable, Comparable<TmfTimestamp> {
// ------------------------------------------------------------------------
// Attributes
return ts2.fValue - ts1.fValue;
}
+ /**
+ * Compute the delta between two timestamps (adjusted to scale of current timestamp).
+ *
+ * @param reference the reference timestamp to synchronize with
+ * @return the delta timestamp
+ * @throws ArithmeticException
+ */
+ public TmfTimestamp getDelta(TmfTimestamp other) throws ArithmeticException {
+ TmfTimestamp newSecond = other;
+ if ((fScale != other.fScale) || (fPrecision != other.fPrecision)) {
+ newSecond = other.synchronize(0, fScale);
+ }
+ return new TmfTimestamp(fValue - newSecond.fValue,
+ fScale,
+ newSecond.fPrecision > fPrecision ? newSecond.fPrecision : fPrecision);
+ }
+
/**
* Compare with another timestamp
*
return clone;
}
+ @Override
+ public int compareTo(TmfTimestamp o) {
+ return compareTo(o, false);
+ }
+
}