tmf: Fix the actual end time of state system modules
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / tmf / core / timestamp / ITmfTimestamp.java
index cc6e79ac049e5dc50ca951216fe72483e77c1841..5d55e5d8e9e2f60f90173c970d6933694d748176 100644 (file)
@@ -77,6 +77,21 @@ public interface ITmfTimestamp extends Comparable<ITmfTimestamp> {
      */
     int getScale();
 
+    /**
+     * Gets the timestamp converted to nanoseconds, if the timestamp is larger
+     * than {@link Long#MAX_VALUE} or smaller than {@link Long#MIN_VALUE} it
+     * will be clamped to those values.
+     *
+     * @return the timestamp converted to a long value of nanoseconds
+     * @since 2.0
+     */
+    default long toNanos() {
+        if (getScale() == NANOSECOND_SCALE) {
+            return getValue();
+        }
+        return normalize(0L, NANOSECOND_SCALE).getValue();
+    }
+
     // ------------------------------------------------------------------------
     // Operations
     // ------------------------------------------------------------------------
This page took 0.024496 seconds and 5 git commands to generate.