- All Implemented Interfaces:
Serializable,Cloneable,Comparable<Date>,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.
- Author:
- harald
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()static TimestampcreateFrozen(long epoch, int nanos) Creates a frozen timestamp.voidfreeze()Makes this object immutable.booleanisUTC()Gets the UTC flag.voidsetDate(int date) Deprecated.voidsetHours(int hours) Deprecated.voidsetMinutes(int minutes) Deprecated.voidsetMonth(int month) Deprecated.voidsetNanos(int n) voidsetSeconds(int seconds) Deprecated.voidsetTime(long timestamp) voidsetUTC(boolean utc) Sets the UTC flag.static voidSets the UTC flag null-safe.
Method provided to reduce generated code.voidsetYear(int year) Deprecated.static TimestampConverts a string into a timestamp.Methods inherited from class java.sql.Timestamp
after, before, compareTo, compareTo, equals, equals, from, getNanos, getTime, hashCode, toInstant, toLocalDateTime, toString, valueOfMethods inherited from class java.util.Date
after, before, getDate, getDay, getHours, getMinutes, getMonth, getSeconds, getTimezoneOffset, getYear, parse, toGMTString, toLocaleString, UTC
-
Constructor Details
-
Timestamp
public Timestamp(long time) Constructs aTimestampobject using a milliseconds time value. The integral seconds are stored in the underlying date value; the fractional seconds are stored in thenanosfield of theTimestampobject.- Parameters:
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.- See Also:
-
Timestamp
public Timestamp()Creates the current timestamp.
-
-
Method Details
-
createFrozen
Creates a frozen timestamp.- Parameters:
epoch- epochal milliseconds since January 1, 1970, 00:00:00 GMTnanos- the new fractional seconds component- Returns:
- the frozen timestamp
-
setUTC
Sets the UTC flag null-safe.
Method provided to reduce generated code.- Parameters:
timestamp- the timestamp, may be nullutc- the UTC flag
-
valueOf
Converts a string into a timestamp.- Parameters:
str- the string- Returns:
- the timestamp
-
clone
Cloned timestamps are always not frozen.
-
setUTC
public void setUTC(boolean utc) Sets the UTC flag.Timestamps with UTC set are serialized and deserialized without timezone.
- Parameters:
utc- the UTC flag
-
isUTC
public boolean isUTC()Gets the UTC flag.- Returns:
- true if timestamp is UTC
-
freeze
public void freeze()Description copied from interface:FreezableMakes this object immutable. -
setTime
public void setTime(long timestamp) Overridden to clear the lazy calendar and to check for frozen.
-
setNanos
public void setNanos(int n) -
setYear
Deprecated. -
setMonth
Deprecated. -
setDate
Deprecated. -
setHours
Deprecated. -
setMinutes
Deprecated.- Overrides:
setMinutesin classDate
-
setSeconds
Deprecated.- Overrides:
setSecondsin classDate
-