- java.lang.Object
-
- java.util.Date
-
- java.sql.Time
-
- org.tentackle.common.Time
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Comparable<java.util.Date>,Freezable
public class Time extends java.sql.Time implements Freezable
Time with database semantics.Differs from
java.sql.Timewhen 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. Injava.sql.Time, however, the epochal time is serialized which may lead to a different time when deserialized in another timezone. InTimethe 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:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Timeclone()static TimecreateFrozen(long epoch)Creates a frozen time.voidfreeze()Makes this object immutable.java.util.CalendargetCalendar()Gets the calendar for this date.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.-
Methods inherited from class java.sql.Time
getDate, getDay, getMonth, getYear, toInstant, toLocalTime, toString, valueOf, valueOf
-
-
-
-
Method Detail
-
createFrozen
public static Time createFrozen(long epoch)
Creates a frozen time.- Parameters:
epoch- epochal milliseconds since January 1, 1970, 00:00:00 GMT- Returns:
- the frozen time
-
clone
public Time clone()
Cloned times are always not frozen.
- Overrides:
clonein classjava.util.Date
-
getCalendar
public java.util.Calendar getCalendar()
Gets the calendar for this date.- Returns:
- the calendar
-
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.
- Overrides:
setTimein classjava.sql.Time
-
setYear
@Deprecated public void setYear(int year)
Deprecated.- Overrides:
setYearin classjava.sql.Time
-
setMonth
@Deprecated public void setMonth(int month)
Deprecated.- Overrides:
setMonthin classjava.sql.Time
-
setDate
@Deprecated public void setDate(int date)
Deprecated.- Overrides:
setDatein classjava.sql.Time
-
setHours
@Deprecated public void setHours(int hours)
Deprecated.- Overrides:
setHoursin classjava.util.Date
-
setMinutes
@Deprecated public void setMinutes(int minutes)
Deprecated.- Overrides:
setMinutesin classjava.util.Date
-
setSeconds
@Deprecated public void setSeconds(int seconds)
Deprecated.- Overrides:
setSecondsin classjava.util.Date
-
-