java.lang.Object
java.util.Date
java.sql.Time
org.tentackle.common.Time
- All Implemented Interfaces:
Serializable,Cloneable,Comparable<Date>,Freezable
Time with database semantics.
Differs from java.sql.Time when
serialized/deserialized in different timezones. Databases don't provide a
date and no timezone for a time, i.e. when sent over wire to different
locations a time should always remain the same for all timezones. In
java.sql.Time, however, the epochal time is serialized which may lead
to a different time when deserialized in another timezone. In Time
the effective date is serialized as HHMMSSmmm to provide the same semantics
as databases do.
Furthermore, tentackle times can be frozen, i.e. made immutable.
- Author:
- harald
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()static TimecreateFrozen(long epoch) Creates a frozen time.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 time) voidsetYear(int year) Deprecated.static TimeConverts a string into a time.Methods inherited from class java.sql.Time
getDate, getDay, getMonth, getYear, toInstant, toLocalTime, toString, valueOfMethods inherited from class java.util.Date
after, before, compareTo, equals, from, getHours, getMinutes, getSeconds, getTime, getTimezoneOffset, hashCode, parse, toGMTString, toLocaleString, UTC
-
Constructor Details
-
Time
public Time(long time) Constructs aTimeobject using a milliseconds time value.- Parameters:
time- milliseconds since January 1, 1970, 00:00:00 GMT; a negative number is milliseconds before January 1, 1970, 00:00:00 GMT
-
Time
public Time()Creates the current time.
-
-
Method Details
-
createFrozen
Creates a frozen time.- Parameters:
epoch- epochal milliseconds since January 1, 1970, 00:00:00 GMT- Returns:
- the frozen time
-
valueOf
Converts a string into a time.- Parameters:
str- the string- Returns:
- the time
-
clone
Cloned times are always not frozen.
-
freeze
public void freeze()Description copied from interface:FreezableMakes this object immutable. -
setTime
public void setTime(long time) Overridden to clear the lazy calendar and check for frozen.
-
setYear
Deprecated. -
setMonth
Deprecated. -
setDate
Deprecated. -
setHours
Deprecated. -
setMinutes
Deprecated.- Overrides:
setMinutesin classDate
-
setSeconds
Deprecated.- Overrides:
setSecondsin classDate
-