java.lang.Object
java.util.Date
java.sql.Date
org.tentackle.common.Date
- All Implemented Interfaces:
Serializable,Cloneable,Comparable<Date>,Freezable
Date with database semantics.
Differs from java.sql.Date when
serialized/deserialized in different timezones. Databases don't provide a
time and therefore no timezone for a date, i.e. when sent over wire to different
locations a date should always remain the same for all timezones. In
java.sql.Data, however, the epochal time is serialized which may lead
to a different date when deserialized in another timezone. In Date
the effective date is serialized as YYYYMMDD to provide the same semantics
as databases do.
Furthermore, tentackle dates can be frozen, i.e. made immutable.
- Author:
- harald
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()static DatecreateFrozen(long epoch) Creates a frozen date.voidfreeze()Makes this object immutable.voidsetDate(int date) Deprecated.voidsetHours(int hours) Deprecated.voidsetMinutes(int minutes) Deprecated.voidsetMonth(int month) Deprecated.voidsetSeconds(int seconds) Deprecated.voidsetTime(long date) voidsetYear(int year) Deprecated.static DateConverts a string into a date.Methods inherited from class java.sql.Date
getHours, getMinutes, getSeconds, toInstant, toLocalDate, toString, valueOf
-
Constructor Details
-
Date
public Date(long date) Constructs aDateobject using the given milliseconds time value. If the given milliseconds value contains time information, the driver will set the time components to the time in the default time zone (the time zone of the Java virtual machine running the application) that corresponds to zero GMT.- Parameters:
date- milliseconds since January 1, 1970, 00:00:00 GMT not to exceed the milliseconds representation for the year 8099. A negative number indicates the number of milliseconds before January 1, 1970, 00:00:00 GMT.
-
Date
public Date()Creates the current date.
-
-
Method Details
-
createFrozen
Creates a frozen date.- Parameters:
epoch- epochal milliseconds since January 1, 1970, 00:00:00 GMT- Returns:
- the frozen date
-
valueOf
Converts a string into a date.- Parameters:
str- the string- Returns:
- the date
-
clone
Cloned dates are always not frozen.
-
freeze
public void freeze()Description copied from interface:FreezableMakes this object immutable. -
setTime
public void setTime(long date) Overridden to clear the lazy calendar and to check for frozen.
-
setYear
Deprecated. -
setMonth
Deprecated. -
setDate
Deprecated. -
setHours
Deprecated. -
setMinutes
Deprecated.- Overrides:
setMinutesin classDate
-
setSeconds
Deprecated.- Overrides:
setSecondsin classDate
-