Class Time

java.lang.Object
java.util.Date
java.sql.Time
org.tentackle.common.Time
All Implemented Interfaces:
Serializable, Cloneable, Comparable<Date>, Freezable

public class Time extends Time implements 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 Details

    • Time

      public Time(long time)
      Constructs a Time object 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

      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
    • valueOf

      public static Time valueOf(String str)
      Converts a string into a time.
      Parameters:
      str - the string
      Returns:
      the time
    • clone

      public Time clone()

      Cloned times are always not frozen.

      Overrides:
      clone in class Date
    • freeze

      public void freeze()
      Description copied from interface: Freezable
      Makes this object immutable.
      Specified by:
      freeze in interface Freezable
    • setTime

      public void setTime(long time)

      Overridden to clear the lazy calendar and check for frozen.

      Overrides:
      setTime in class Time
    • setYear

      @Deprecated public void setYear(int year)
      Deprecated.
      Overrides:
      setYear in class Time
    • setMonth

      @Deprecated public void setMonth(int month)
      Deprecated.
      Overrides:
      setMonth in class Time
    • setDate

      @Deprecated public void setDate(int date)
      Deprecated.
      Overrides:
      setDate in class Time
    • setHours

      @Deprecated public void setHours(int hours)
      Deprecated.
      Overrides:
      setHours in class Date
    • setMinutes

      @Deprecated public void setMinutes(int minutes)
      Deprecated.
      Overrides:
      setMinutes in class Date
    • setSeconds

      @Deprecated public void setSeconds(int seconds)
      Deprecated.
      Overrides:
      setSeconds in class Date