public final class Timestamp extends Object implements Comparable<Timestamp>, Serializable
Represents an unmodifiable timestamp value supporting millisecond granularity. Timestamps are based on the given amount of milliseconds elapsed since the beginning of the year 1970. 1970 as reference start date is known as The Epoch in Unix/POSIX time system.
Due to long
data type, the maximum year that can be covered
completely with Timestamp
class is 292,278,993.
Note that, the Unix/POSIX time system (and this Java class) considers each day to be exactly 86,400 seconds long. By contrast, the Coordinated Universal Time (UTC) has "leap seconds" in order to synchronize the calendar to astronomical irregularities in Earth rotation. Thereby a day may have 86,401 seconds. This correction happens approximately every 1.5 years.
Modifier and Type | Field and Description |
---|---|
static Timestamp |
AD_ERA_START
Timestamp for beginning of January 1st of year 1 AD/CE in Western calendars.
|
static Timestamp |
EPOCH_START
The
Timestamp representing The Epoch start. |
static Timestamp |
MAX
The maximum possible
Timestamp . |
static Timestamp |
MIN
The minimum possible
Timestamp . |
Modifier and Type | Method and Description |
---|---|
Timestamp |
add(Duration duration)
Create a new
Timestamp instance with a specified amount of
milliseconds added. |
int |
compareTo(Timestamp other) |
boolean |
equals(Object object) |
static Timestamp |
fromDate(Date date)
Creates a
Timestamp instance based on the given date. |
static Timestamp |
fromMillisecondsSince1970(long millisecondsSince1970)
Creates a
Timestamp instance based on the given amount of
milliseconds elapsed since the beginning of the year 1970. |
int |
hashCode() |
static Timestamp |
max(Timestamp first,
Timestamp second)
Determine the maximum of two timestamps.
|
long |
millisecondsSince1970()
The milliseconds since 1970 corresponding to this
Timestamp
without leap seconds. |
static Timestamp |
min(Timestamp first,
Timestamp second)
Determine the minimum of two timestamps.
|
boolean |
precedes(Timestamp other)
Check whether the timestamp precedes another one.
|
boolean |
precedesOrEquals(Timestamp other)
Check whether the timestamp precedes or equals another one.
|
boolean |
succeeds(Timestamp other)
Check whether the timestamp succeeds another one.
|
boolean |
succeedsOrEquals(Timestamp other)
Check whether the timestamp succeeds or equals another one.
|
Date |
toDate()
Returns the date corresponding to this timestamp.
|
String |
toString()
Returns the timestamp as number of milliseconds since 1970 (UNIX Epoch).
|
public static final Timestamp EPOCH_START
Timestamp
representing The Epoch start.public static final Timestamp AD_ERA_START
public static final Timestamp MIN
Timestamp
.public static final Timestamp MAX
Timestamp
.public long millisecondsSince1970()
Timestamp
without leap seconds.Timestamp
without leap secondspublic Timestamp add(Duration duration)
Timestamp
instance with a specified amount of
milliseconds added.duration
- the duration to be added to the new Timestamp
instanceTimestamp
instance with the specified amount
of milliseconds addedpublic boolean precedes(Timestamp other)
other
- the other timestamp to be compared totrue
if the timestamp precedes the other,
false
otherwisepublic boolean precedesOrEquals(Timestamp other)
other
- the other timestamp to be compared totrue
if the timestamp precedes or equals the other,
false
otherwesepublic boolean succeeds(Timestamp other)
other
- the other timestamp to be compared totrue
if the timestamp succeeds the other,
false
otherwisepublic boolean succeedsOrEquals(Timestamp other)
other
- the other timestamp to be compared totrue
if the timestamp succeeds or equals the other,
false
otherwisepublic int compareTo(Timestamp other)
compareTo
in interface Comparable<Timestamp>
public String toString()
TimestampFormat
for more readable outputs.public Date toDate()
public static final Timestamp min(Timestamp first, Timestamp second)
first
- the first timestamp to be compared.second
- the second timestamp to be compared.public static final Timestamp max(Timestamp first, Timestamp second)
first
- the first timestamp to be compared.second
- the second timestamp to be compared.public static Timestamp fromMillisecondsSince1970(long millisecondsSince1970)
Timestamp
instance based on the given amount of
milliseconds elapsed since the beginning of the year 1970.millisecondsSince1970
- the amount of milliseconds since 1970Copyright © Aimpulse Intelligent Systems GmbH
All rights reserved.