Contribution for Bug352466: [TMF] Implement UML2 Sequence Diagram
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf / src / org / eclipse / linuxtools / tmf / event / TmfTimestamp.java
index b786e3dd309d0e0de640a17e7a05c17864a54c6c..63168db9afa698226967101ed18b6f248ba3106f 100644 (file)
@@ -256,6 +256,23 @@ public class TmfTimestamp implements Cloneable {
         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
      * 
This page took 0.035441 seconds and 5 git commands to generate.