Class TimeInstant

java.lang.Object
com.seeq.link.sdk.utilities.TimeInstant

public class TimeInstant extends Object
Representation of a Seeq timestamp which is a count of nanoseconds elapsed since Unix Epoch (January 1, 1970 UTC).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static Pattern
     
    static final TimeInstant
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    TimeInstant(long timestamp)
    Construct a new TimeInstant with the count of nanoseconds elapsed since Unix Epoch (January 1, 1970 UTC).
    Construct a new TimeInstant from a Java ZonedDateTime.
  • Method Summary

    Modifier and Type
    Method
    Description
    static long
    Converts a Java LocalDateTime to a Seeq timestamp which is a count of nanoseconds elapsed since Unix Epoch (January 1, 1970 UTC).
    static long
    Converts a Java ZonedDateTime to a Seeq timestamp which is a count of nanoseconds elapsed since Unix Epoch (January 1, 1970 UTC).
    Subtract a nanosecond from this time.
    long
    Represents a Seeq timestamp which is a count of nanoseconds elapsed since Unix Epoch (January 1, 1970 UTC).
    Add a nanosecond to this time.
    Parses a string in the ISO format "2021-02-14T15:23:54.384758575Z" into a TimeInstant.
    roundDown(long multiple_ns)
    Round down a TimeInstant to a multiple of nanoseconds.
    Example: TimeInstant = 1232 ns.
    static long
    roundTimestampDown(long timestamp, long multiple)
    Round down a timestamp to a multiple of 1, 10, 100, etc.
    Example: roundTimestampDown( 1232,100) = 1200
    Example: roundTimestampDown(-1232,100) = -1300
    static long
    roundTimestampUp(long timestamp, long multiple)
    Round up a timestamp to a multiple of 1, 10, 100, etc.
    Example: roundTimestampUp( 1232,100) = 1300
    Example: roundTimestampUp(-1232,100) = -1200
    roundUp(long multiple_ns)
    Round up a TimeInstant to a multiple of nanoseconds.
    Example: TimeInstant = 1232 ns.
    timestampToDateTime(long timestamp)
    Converts a Seeq timestamp to a Java UTC DateTime.
    Retrieves the TimeInstant as a Java UTC DateTime.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • MIN

      public static final TimeInstant MIN
    • ISO_TIMESTAMP_REGEX

      public static Pattern ISO_TIMESTAMP_REGEX
  • Constructor Details

    • TimeInstant

      public TimeInstant(long timestamp)
      Construct a new TimeInstant with the count of nanoseconds elapsed since Unix Epoch (January 1, 1970 UTC).
      Parameters:
      timestamp - Number of nanoseconds elapsed since Unix Epoch (January 1, 1970 UTC).
    • TimeInstant

      public TimeInstant(ZonedDateTime dateTime)
      Construct a new TimeInstant from a Java ZonedDateTime.
      Parameters:
      dateTime - The time that the TimeInstant is to represent.
  • Method Details

    • getTimestamp

      public long getTimestamp()
      Represents a Seeq timestamp which is a count of nanoseconds elapsed since Unix Epoch (January 1, 1970 UTC). Seeq timestamps are always in UTC.
      Returns:
      the timestamp
    • toDateTime

      public ZonedDateTime toDateTime()
      Retrieves the TimeInstant as a Java UTC DateTime.
      Returns:
      The Java UTC DateTime representation of the TimeInstant.
    • timestampToDateTime

      public static ZonedDateTime timestampToDateTime(long timestamp)
      Converts a Seeq timestamp to a Java UTC DateTime. Seeq timestamps are a count of nanoseconds elapsed since Unix Epoch (January 1, 1970 UTC).
      Parameters:
      timestamp - Number of nanoseconds elapsed since Unix Epoch (January 1, 1970 UTC).
      Returns:
      The UTC DateTime representation of the Seeq timestamp.
    • dateTimeToTimestamp

      public static long dateTimeToTimestamp(ZonedDateTime dateTime)
      Converts a Java ZonedDateTime to a Seeq timestamp which is a count of nanoseconds elapsed since Unix Epoch (January 1, 1970 UTC).
      Parameters:
      dateTime - The Java DateTime that the timestamp is to represent.
      Returns:
      The Seeq timestamp representation of the .Net DateTime.
    • dateTimeToTimestamp

      public static long dateTimeToTimestamp(LocalDateTime dateTime)
      Converts a Java LocalDateTime to a Seeq timestamp which is a count of nanoseconds elapsed since Unix Epoch (January 1, 1970 UTC).
      Parameters:
      dateTime - The Java DateTime that the timestamp is to represent.
      Returns:
      The Seeq timestamp representation of the .Net DateTime.
    • roundUp

      public TimeInstant roundUp(long multiple_ns)
      Round up a TimeInstant to a multiple of nanoseconds.
      Example: TimeInstant = 1232 ns. TimeInstant.roundUp(100) = 1300 ns
      Example: TimeInstant = -1232 ns. TimeInstant.roundUp(100)= -1200 ns
      Parameters:
      multiple_ns - The multiple of nanoseconds to round to such as 1, 10, 100, 1000 etc
      Returns:
      The rounded result
    • roundTimestampUp

      public static long roundTimestampUp(long timestamp, long multiple)
      Round up a timestamp to a multiple of 1, 10, 100, etc.
      Example: roundTimestampUp( 1232,100) = 1300
      Example: roundTimestampUp(-1232,100) = -1200
      Parameters:
      timestamp - The timestamp to round
      multiple - The multiple to round to such as 1, 10, 100, 1000 etc
      Returns:
      The rounded result
    • roundDown

      public TimeInstant roundDown(long multiple_ns)
      Round down a TimeInstant to a multiple of nanoseconds.
      Example: TimeInstant = 1232 ns. TimeInstant.roundUp(100) = 1200 ns
      Example: TimeInstant = -1232 ns. TimeInstant.roundUp(100)= -1300 ns
      Parameters:
      multiple_ns - The multiple of nanoseconds to round to such as 1, 10, 100, 1000 etc
      Returns:
      The rounded result
    • decrement

      public TimeInstant decrement()
      Subtract a nanosecond from this time.
      Returns:
      The time exactly 1 nanosecond previous to the time represented by this instance.
      Throws:
      ArithmeticException - If this timestamp is already at the minimum representable time.
    • increment

      public TimeInstant increment()
      Add a nanosecond to this time.
      Returns:
      The time exactly 1 nanosecond after the time represented by this instance.
      Throws:
      ArithmeticException - If this timestamp is already at the maximum representable time.
    • roundTimestampDown

      public static long roundTimestampDown(long timestamp, long multiple)
      Round down a timestamp to a multiple of 1, 10, 100, etc.
      Example: roundTimestampDown( 1232,100) = 1200
      Example: roundTimestampDown(-1232,100) = -1300
      Parameters:
      timestamp - The timestamp to round
      multiple - The multiple to round to such as 1, 10, 100, 1000 etc
      Returns:
      The rounded result
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • parseIso

      public static TimeInstant parseIso(String str)
      Parses a string in the ISO format "2021-02-14T15:23:54.384758575Z" into a TimeInstant. Note that only this string format is supported. Sub-nanosecond precision will be ignored (floored).
      Parameters:
      str - A string in ISO format "2021-02-14T15:23:54.384758575Z"
      Returns:
      The TimeInstant corresponding to the specified string.