Class Timespec

java.lang.Object
net.quasardb.qdb.ts.Timespec
All Implemented Interfaces:
Serializable, Comparable<Timespec>

public class Timespec extends Object implements Serializable, Comparable<Timespec>
Nanosecond precision time specification for QuasarDB. Allows construction from multiple different clock sources, and interaction with the QuasarDB backend.
See Also:
  • Field Details

    • MIN_VALUE

      public static final Timespec MIN_VALUE
      Lowest possible representable time (identical to epoch).
    • MAX_VALUE

      public static final Timespec MAX_VALUE
      Largest possible representable time.
    • sec

      protected long sec
    • nsec

      protected long nsec
  • Constructor Details

    • Timespec

      public Timespec()
      Construct a new Timespec null value. Constants align with what is used by QuasarDB in the backend.
    • Timespec

      public Timespec(long msec)
      Construct a new timespec from milliseconds.
    • Timespec

      public Timespec(long sec, long nsec)
    • Timespec

      public Timespec(LocalDateTime value)
    • Timespec

      public Timespec(Timestamp value)
    • Timespec

      public Timespec(Instant value)
    • Timespec

      public Timespec(Timespec value)
      Create a copy of this timespec.
  • Method Details

    • getSec

      public long getSec()
    • setSec

      public void setSec(long sec)
    • getNano

      public long getNano()
    • setNano

      public void setNano(long nsec)
    • isBefore

      public boolean isBefore(Timespec rhs)
    • isEmpty

      public boolean isEmpty()
    • now

      public static Timespec now()
      Construct a new Timespec based on a NanoClock that provides nanosecond precision.
      See Also:
    • now

      public static Timespec now(Clock clock)
      Construct a new Timespec using your own custom Clock.
    • plusSeconds

      public Timespec plusSeconds(long secondsToAdd)
      Returns copy of this instance with the specified duration in seconds added.
    • plusNanos

      public Timespec plusNanos(long nanosToAdd)
      Returns copy of this instance with the specified duration in nanoseconds added.
    • minusSeconds

      public Timespec minusSeconds(long secondsToDeduct)
      Returns copy of this instance with the specified duration in seconds deducted.
    • minusNanos

      public Timespec minusNanos(long nanosToDeduct)
      Returns copy of this instance with the specified duration in nanoseconds deducted.
    • asInstant

      public Instant asInstant()
      Converts this Timespec into an Instant.
    • asLocalDateTime

      public LocalDateTime asLocalDateTime()
      Converts this Timespec into an LocalDateTime.
    • asTimestamp

      public Timestamp asTimestamp()
      Converts this Timespec into an sql Timestamp.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • compareTo

      public int compareTo(Timespec rhs)
      Specified by:
      compareTo in interface Comparable<Timespec>
    • toString

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

      public long toEpochMillis()
      Converts this timespec to the number of milliseconds from the epoch of 1970-01-01
    • toEpochNanos

      public long toEpochNanos()
      Converts this timespec to the number of nanoseconds from the epoch of 1970-01-01
    • min

      public static Timespec min(Timespec lhs, Timespec rhs)
      Returns the smallest timespec between the two, that is, the time that is pointing towards the earliest point in time.
    • max

      public static Timespec max(Timespec lhs, Timespec rhs)
      Returns the smallest timespec between the two, that is, the time that is pointing towards the latest point in time.