Class TimeStamp

    • Method Detail

      • fromPosixSeconds

        public static TimeStamp fromPosixSeconds​(double posixSeconds)
        Converts a timestamp in posix seconds to a TimeStamp.
        Parameters:
        posixSeconds - seconds since the epoch
      • fromPosixSeconds

        public static TimeStamp fromPosixSeconds​(BigDecimal posixSeconds)
        Converts a timestamp in posix seconds to a TimeStamp.
        Parameters:
        posixSeconds - seconds since the epoch
      • fromPosixMillis

        public static TimeStamp fromPosixMillis​(long posixMillis)
        Converts a timestamp in posix milliseconds to a TimeStamp.
        Parameters:
        posixMillis - milliseconds since the epoch
      • fromPosixMicros

        public static TimeStamp fromPosixMicros​(long posixMicros)
        Converts a timestamp in posix microseconds to a TimeStamp.
        Parameters:
        posixMicros - microseconds since the epoch
      • fromPosixNanos

        public static TimeStamp fromPosixNanos​(long posixNanos)
        Converts a timestamp in posix nanoseconds to a TimeStamp.
        Parameters:
        posixNanos - nanoseconds since the epoch
      • fromTimeStamp

        public static TimeStamp fromTimeStamp​(TimeStamp timeStamp)
        Converts a TimeStamp of any subclass to a TimeStamp of the default subclass.
        Throws:
        NullPointerException - if argument is null
      • posixEpoch

        public static TimeStamp posixEpoch()
        Returns a TimeStamp that represents the posix epoch.
      • currentTime

        public static TimeStamp currentTime()
        Creates a TimeStamp that represents the current system time. The precision may be limited by the precision of Java's access to the system clock.
      • add

        public abstract TimeStamp add​(double duration)
        Creates a new TimeStamp instance offset from this timestamp by the given amount. The returned instance may or may not be of the same dynamic type as this instance.
        Parameters:
        duration - the amount of time to add in system-units
      • subtract

        public abstract TimeStamp subtract​(double duration)
        Creates a new TimeStamp instance offset from this timestamp by the given amount. The returned instance may or may not be of the same dynamic type as this instance.
        Parameters:
        duration - the amount of time to subtract in system-units
      • durationBefore

        public double durationBefore​(TimeStamp o)
        Determines how long before the given timestamp this timestamp is. That is: durationBefore = other - this In the base-class implementation, arithmetic is done with BigDecimal. This is quite effective at minimizing rounding error, but may be slow compared to primitive arithmetic.
        Returns:
        the difference, in system-units
        Throws:
        NullPointerException - if argument is null
      • durationAfter

        public double durationAfter​(TimeStamp o)
        Determines how long after the given timestamp this timestamp is. That is: durationAfter = this - other In the base-class implementation, arithmetic is done with BigDecimal. This is quite effective at minimizing rounding error, but may be slow compared to primitive arithmetic.
        Returns:
        the difference, in system-units
        Throws:
        NullPointerException - if argument is null
      • toPosixSeconds

        public abstract double toPosixSeconds()
        Converts this TimeStamp to posix seconds.
        Returns:
        seconds since the epoch
      • toPosixMillis

        public abstract long toPosixMillis()
        Converts this TimeStamp to posix milliseconds.
        Returns:
        milliseconds since the epoch
      • toPosixMicros

        public abstract long toPosixMicros()
        Converts this TimeStamp to posix microseconds.
        Returns:
        microseconds since the epoch
      • toPosixNanos

        public abstract long toPosixNanos()
        Converts this TimeStamp to posix nanoseconds.
        Returns:
        nanoseconds since the epoch
      • toDate

        public abstract Date toDate()
        Converts this TimeStamp to a Date.
      • toCalendar

        public abstract Calendar toCalendar()
        Converts this TimeStamp to a Calendar.
      • toPosixSecondsExact

        public abstract BigDecimal toPosixSecondsExact()
        Converts this TimeStamp to posix seconds. The returned representation is exact (see note). NOTE: In theory, it is possible to have a subclass that stores its value in a form that cannot be exactly converted to a BigDecimal (e.g., thirds of a second). Such subclasses are discouraged. If such a subclass is unavoidable, its documentation must note prominently that it breaks the contract of the TimeStamp interface, and its implementation of this method must return values as exact as is practical.
        Returns:
        seconds since the epoch
      • isBefore

        public boolean isBefore​(TimeStamp o)
        Returns true iff this timestamp is before the given timestamp.
        Throws:
        NullPointerException - if argument is null
      • isBeforeOrEquals

        public boolean isBeforeOrEquals​(TimeStamp o)
        Returns true iff this timestamp is before or equal to the given timestamp.
        Throws:
        NullPointerException - if argument is null
      • isAfter

        public boolean isAfter​(TimeStamp o)
        Returns true iff this timestamp is after the given timestamp.
        Throws:
        NullPointerException - if argument is null
      • isAfterOrEquals

        public boolean isAfterOrEquals​(TimeStamp o)
        Returns true iff this timestamp is after or equal to the given timestamp.
        Throws:
        NullPointerException - if argument is null
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object