Class 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:
    Serialized Form
    • Constructor Detail

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