Package net.quasardb.qdb.ts
Class Timespec
java.lang.Object
net.quasardb.qdb.ts.Timespec
- All Implemented Interfaces:
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTimespec()
Construct a new Timespec null value.Timespec
(long msec) Construct a new timespec from milliseconds.Timespec
(long sec, long nsec) Timespec
(LocalDateTime value) Create a copy of this timespec. -
Method Summary
Modifier and TypeMethodDescriptionConverts this Timespec into anInstant
.Converts this Timespec into anLocalDateTime
.Converts this Timespec into an sqlTimestamp
.int
boolean
long
getNano()
long
getSec()
boolean
boolean
isEmpty()
static Timespec
Returns the smallest timespec between the two, that is, the time that is pointing towards the latest point in time.static Timespec
Returns the smallest timespec between the two, that is, the time that is pointing towards the earliest point in time.minusNanos
(long nanosToDeduct) Returns copy of this instance with the specified duration in nanoseconds deducted.minusSeconds
(long secondsToDeduct) Returns copy of this instance with the specified duration in seconds deducted.static Timespec
now()
Construct a new Timespec based on aNanoClock
that provides nanosecond precision.static Timespec
Construct a new Timespec using your own custom Clock.plusNanos
(long nanosToAdd) Returns copy of this instance with the specified duration in nanoseconds added.plusSeconds
(long secondsToAdd) Returns copy of this instance with the specified duration in seconds added.void
setNano
(long nsec) void
setSec
(long sec) long
Converts this timespec to the number of milliseconds from the epoch of 1970-01-01long
Converts this timespec to the number of nanoseconds from the epoch of 1970-01-01toString()
-
Field Details
-
MIN_VALUE
Lowest possible representable time (identical to epoch). -
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
-
Timespec
-
Timespec
-
Timespec
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
-
isEmpty
public boolean isEmpty() -
now
Construct a new Timespec based on aNanoClock
that provides nanosecond precision.- See Also:
-
now
Construct a new Timespec using your own custom Clock. -
plusSeconds
Returns copy of this instance with the specified duration in seconds added. -
plusNanos
Returns copy of this instance with the specified duration in nanoseconds added. -
minusSeconds
Returns copy of this instance with the specified duration in seconds deducted. -
minusNanos
Returns copy of this instance with the specified duration in nanoseconds deducted. -
asInstant
Converts this Timespec into anInstant
. -
asLocalDateTime
Converts this Timespec into anLocalDateTime
. -
asTimestamp
Converts this Timespec into an sqlTimestamp
. -
equals
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Timespec>
-
toString
-
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
Returns the smallest timespec between the two, that is, the time that is pointing towards the earliest point in time. -
max
Returns the smallest timespec between the two, that is, the time that is pointing towards the latest point in time.
-