public abstract class TimeStamp extends Object implements Comparable<TimeStamp>, Serializable
Modifier and Type | Field and Description |
---|---|
static TimeStampFormat |
defaultFormat
The format used by the convenience methods
fromString(String) and
toString() . |
Modifier and Type | Method and Description |
---|---|
abstract TimeStamp |
add(double duration)
Creates a new TimeStamp instance offset from this timestamp by the given
amount.
|
int |
compareTo(TimeStamp o) |
static TimeStamp |
currentTime()
Creates a TimeStamp that represents the current system time.
|
double |
durationAfter(TimeStamp o)
Determines how long after the given timestamp this timestamp is.
|
double |
durationBefore(TimeStamp o)
Determines how long before the given timestamp this timestamp is.
|
boolean |
equals(Object o) |
static TimeStamp |
fromCalendar(Calendar calendar)
Converts a
Calendar to a TimeStamp. |
static TimeStamp |
fromDate(Date date)
Converts a
Date to a TimeStamp. |
static TimeStamp |
fromPosixMicros(long posixMicros)
Converts a timestamp in posix microseconds to a TimeStamp.
|
static TimeStamp |
fromPosixMillis(long posixMillis)
Converts a timestamp in posix milliseconds to a TimeStamp.
|
static TimeStamp |
fromPosixNanos(long posixNanos)
Converts a timestamp in posix nanoseconds to a TimeStamp.
|
static TimeStamp |
fromPosixSeconds(BigDecimal posixSeconds)
Converts a timestamp in posix seconds to a TimeStamp.
|
static TimeStamp |
fromPosixSeconds(double posixSeconds)
Converts a timestamp in posix seconds to a TimeStamp.
|
static TimeStamp |
fromString(String string)
Converts a
String to a TimeStamp, using defaultFormat . |
static TimeStamp |
fromString(String string,
TimeStampFormat format)
Converts a
String to a TimeStamp. |
static TimeStamp |
fromTimeStamp(TimeStamp timeStamp)
Converts a TimeStamp of any subclass to a TimeStamp of the default subclass.
|
int |
hashCode() |
boolean |
isAfter(TimeStamp o)
Returns true iff this timestamp is after the given timestamp.
|
boolean |
isAfterOrEquals(TimeStamp o)
Returns true iff this timestamp is after or equal to the given timestamp.
|
boolean |
isBefore(TimeStamp o)
Returns true iff this timestamp is before the given timestamp.
|
boolean |
isBeforeOrEquals(TimeStamp o)
Returns true iff this timestamp is before or equal to the given timestamp.
|
static TimeStamp |
posixEpoch()
Returns a TimeStamp that represents the posix epoch.
|
abstract TimeStamp |
subtract(double duration)
Creates a new TimeStamp instance offset from this timestamp by the given
amount.
|
abstract Calendar |
toCalendar()
Converts this TimeStamp to a
Calendar . |
abstract Date |
toDate()
Converts this TimeStamp to a
Date . |
abstract long |
toPosixMicros()
Converts this TimeStamp to posix microseconds.
|
abstract long |
toPosixMillis()
Converts this TimeStamp to posix milliseconds.
|
abstract long |
toPosixNanos()
Converts this TimeStamp to posix nanoseconds.
|
abstract double |
toPosixSeconds()
Converts this TimeStamp to posix seconds.
|
abstract BigDecimal |
toPosixSecondsExact()
Converts this TimeStamp to posix seconds.
|
String |
toString()
Converts this timestamp to a
String , according to defaultFormat . |
String |
toString(TimeStampFormat format)
Converts this timestamp to a
String , according to the given format. |
public static final TimeStampFormat defaultFormat
fromString(String)
and
toString()
. It refers to TimeStampFormat.iso8601
.public static TimeStamp fromPosixSeconds(double posixSeconds)
posixSeconds
- seconds since the epochpublic static TimeStamp fromPosixSeconds(BigDecimal posixSeconds)
posixSeconds
- seconds since the epochpublic static TimeStamp fromPosixMillis(long posixMillis)
posixMillis
- milliseconds since the epochpublic static TimeStamp fromPosixMicros(long posixMicros)
posixMicros
- microseconds since the epochpublic static TimeStamp fromPosixNanos(long posixNanos)
posixNanos
- nanoseconds since the epochpublic static TimeStamp fromTimeStamp(TimeStamp timeStamp)
NullPointerException
- if argument is nullpublic static TimeStamp fromDate(Date date)
Date
to a TimeStamp.NullPointerException
- if argument is nullpublic static TimeStamp fromCalendar(Calendar calendar)
Calendar
to a TimeStamp.NullPointerException
- if argument is nullpublic static TimeStamp fromString(String string, TimeStampFormat format) throws TimeStampParseException
String
to a TimeStamp.NullPointerException
- if either argument is nullTimeStampParseException
- if string parsing failspublic static TimeStamp fromString(String string) throws TimeStampParseException
String
to a TimeStamp, using defaultFormat
.NullPointerException
- if either argument is nullTimeStampParseException
- if string parsing failspublic static TimeStamp posixEpoch()
public static TimeStamp currentTime()
public abstract TimeStamp add(double duration)
duration
- the amount of time to add in system-unitspublic abstract TimeStamp subtract(double duration)
duration
- the amount of time to subtract in system-unitspublic double durationBefore(TimeStamp o)
NullPointerException
- if argument is nullpublic double durationAfter(TimeStamp o)
NullPointerException
- if argument is nullpublic abstract double toPosixSeconds()
public abstract long toPosixMillis()
public abstract long toPosixMicros()
public abstract long toPosixNanos()
public abstract BigDecimal toPosixSecondsExact()
public boolean isBefore(TimeStamp o)
NullPointerException
- if argument is nullpublic boolean isBeforeOrEquals(TimeStamp o)
NullPointerException
- if argument is nullpublic boolean isAfter(TimeStamp o)
NullPointerException
- if argument is nullpublic boolean isAfterOrEquals(TimeStamp o)
NullPointerException
- if argument is nullpublic int compareTo(TimeStamp o)
compareTo
in interface Comparable<TimeStamp>
public String toString(TimeStampFormat format)
String
, according to the given format.public String toString()
String
, according to defaultFormat
.Copyright © 2020 Metron, Inc.. All rights reserved.