public class Timestamp extends Timestamp implements Freezable
Differs from java.sql.Timestamp when
serialized/deserialized in different timezones.
By default, if timestamps are serialized and deserialized in different timezones,
their representation may differ according to the GMT-offset and/or daylight saving.
This is okay for most cases. In some cases, however, a timestamp
should not be converted, i.e. regarded as fixed and related to some
timezone by convention, for example UTC. This is what the UTC-attribute
and the tentackle model's [UTC]-option is provided for.
Furthermore, tentackle timestamps can be frozen, i.e. made immutable.
| Constructor and Description |
|---|
Timestamp()
Creates the current timestamp.
|
Timestamp(long time)
Constructs a
Timestamp object using a milliseconds time value. |
| Modifier and Type | Method and Description |
|---|---|
Timestamp |
clone() |
static Timestamp |
createFrozen(long epoch,
int nanos)
Creates a frozen timestamp.
|
void |
freeze()
Makes this object immutable.
|
Calendar |
getCalendar()
Gets the calendar for this date.
|
boolean |
isUTC()
Gets the UTC flag.
|
void |
setDate(int date) |
void |
setHours(int hours) |
void |
setMinutes(int minutes) |
void |
setMonth(int month) |
void |
setNanos(int n) |
void |
setSeconds(int seconds) |
void |
setTime(long timestamp) |
void |
setUTC(boolean utc)
Sets the UTC flag.
|
static void |
setUTC(Timestamp timestamp,
boolean utc)
Sets the UTC flag null-safe.
Method provided to reduce generated code. |
void |
setYear(int year) |
after, before, compareTo, compareTo, equals, equals, from, getNanos, getTime, hashCode, toInstant, toLocalDateTime, toString, valueOf, valueOfafter, before, getDate, getDay, getHours, getMinutes, getMonth, getSeconds, getTimezoneOffset, getYear, parse, toGMTString, toLocaleString, UTCpublic Timestamp(long time)
Timestamp object using a milliseconds time value. The integral
seconds are stored in the underlying date value; the fractional seconds are
stored in the
nanos field of the
Timestamp object.time - milliseconds since January 1, 1970, 00:00:00 GMT. A negative
number is the number of milliseconds before January 1, 1970, 00:00:00 GMT.Calendarpublic Timestamp()
public static Timestamp createFrozen(long epoch, int nanos)
epoch - epochal milliseconds since January 1, 1970, 00:00:00 GMTnanos - the new fractional seconds componentpublic static void setUTC(Timestamp timestamp, boolean utc)
timestamp - the timestamp, may be nullutc - the UTC flagpublic Timestamp clone()
Cloned timestamps are always not frozen.
public void setUTC(boolean utc)
Timestamps with UTC set are serialized and deserialized without timezone.
utc - the UTC flagpublic boolean isUTC()
public Calendar getCalendar()
public void freeze()
Freezablepublic void setTime(long timestamp)
Overridden to clear the lazy calendar and to check for frozen.
public void setMinutes(int minutes)
setMinutes in class Datepublic void setSeconds(int seconds)
setSeconds in class DateTentackle - distributed, domain- and model-driven