public final class EpochTime extends java.lang.Object implements java.lang.Comparable<EpochTime>, UsesCustomNull
Date
, i.e.
milliseconds since 1970. We don't use Date
because it is mutable,
which makes certain APIs in SweetBlue harder to design.Modifier and Type | Field and Description |
---|---|
static EpochTime |
MAX
Convenience instance using
Long.MAX_VALUE . |
static EpochTime |
MIN
Convenience instance using
Long.MIN_VALUE . |
static EpochTime |
NULL
Fulfills the soft contract of
UsesCustomNull - used for isNull() . |
static EpochTime |
ZERO
Convenience instance representing the start date of 1970.
|
Constructor and Description |
---|
EpochTime()
Constructs a new instance using
System.currentTimeMillis() . |
EpochTime(java.util.Date date)
Converts from Java's built-in date.
|
EpochTime(long millisecondsSince1970)
Constructs a new instance using milliseconds since 1970.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(EpochTime another) |
boolean |
isBetween_inclusive(EpochTime from,
EpochTime to)
Does an inclusive check for
this being in the given range. |
boolean |
isBetween_inclusive(EpochTimeRange range)
Overload of
isBetween_inclusive(EpochTime, EpochTime) . |
boolean |
isNull()
|
EpochTimeRange |
minus(EpochTime epochTime)
Returns the delta resulting from
this-epochTime . |
static EpochTime |
now()
Simply a more readable version of the default constructor
EpochTime() . |
java.util.Date |
toDate()
Converts to Java's built-in date class.
|
long |
toMilliseconds()
Converts to milliseconds since 1970, which is currently also how the value is stored internally.
|
double |
toSeconds()
Converts to seconds since 1970.
|
java.lang.String |
toString() |
public static final EpochTime NULL
UsesCustomNull
- used for isNull()
.public static final EpochTime MIN
Long.MIN_VALUE
.public static final EpochTime MAX
Long.MAX_VALUE
.public static final EpochTime ZERO
public EpochTime(java.util.Date date)
public EpochTime(long millisecondsSince1970)
public EpochTime()
System.currentTimeMillis()
.public static EpochTime now()
EpochTime()
.public long toMilliseconds()
public double toSeconds()
public java.util.Date toDate()
public boolean isBetween_inclusive(EpochTime from, EpochTime to)
this
being in the given range.public boolean isBetween_inclusive(EpochTimeRange range)
isBetween_inclusive(EpochTime, EpochTime)
.public int compareTo(EpochTime another)
compareTo
in interface java.lang.Comparable<EpochTime>
public EpochTimeRange minus(EpochTime epochTime)
this-epochTime
.public boolean isNull()
isNull
in interface UsesCustomNull
public java.lang.String toString()
toString
in class java.lang.Object