*/
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
// ------------------------------------------------------------------------
/**
* Full constructor
*
- * @param value the timestamp value
+ * @param value
+ * the timestamp value
*/
public TmfNanoTimestamp(final long value) {
super(value, ITmfTimestamp.NANOSECOND_SCALE);
/**
* Copy constructor.
*
- * If the parameter is not a TmfNanoTimestamp, the timestamp will be
- * scaled to nanoseconds, and the precision will be discarded.
+ * If the parameter is not a TmfNanoTimestamp, the timestamp will be scaled
+ * to nanoseconds, and the precision will be discarded.
*
* @param timestamp
* The timestamp to copy
return super.getDelta(ts);
}
+ /**
+ * @since 2.0
+ */
+ @Override
+ public long toNanos(){
+ return getValue();
+ }
+
// ------------------------------------------------------------------------
// Object
// ------------------------------------------------------------------------