com.metsci.glimpse.util.units.time
Class TimeStampPosixMillisInt64

java.lang.Object
  extended by com.metsci.glimpse.util.units.time.TimeStamp
      extended by com.metsci.glimpse.util.units.time.TimeStampPosixMillisInt64
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<TimeStamp>

public class TimeStampPosixMillisInt64
extends TimeStamp
implements java.io.Serializable

A TimeStamp implementation that stores the number of milliseconds since the epoch (1970-01-01 00:00:00 UTC) as a long.

Advantages of this implementation:

Disadvantanges of this implementation:

Author:
hogye
See Also:
Serialized Form

Field Summary
static TimeStampFactory<TimeStampPosixMillisInt64> factory
           
 
Fields inherited from class com.metsci.glimpse.util.units.time.TimeStamp
defaultFormat
 
Method Summary
 TimeStampPosixMillisInt64 add(double duration)
          Creates a new TimeStamp instance offset from this timestamp by the given amount.
 int compareTo(TimeStamp o)
           
 double durationAfter(TimeStamp o)
          Determines how long after the given timestamp this timestamp is.
 double durationBefore(TimeStamp o)
          Determines how long before the given timestamp this timestamp is.
 boolean equals(java.lang.Object o)
           
 int hashCode()
           
 boolean isAfter(TimeStamp o)
          Returns true iff this timestamp is after the given timestamp.
 boolean isBefore(TimeStamp o)
          Returns true iff this timestamp is before the given timestamp.
 TimeStampPosixMillisInt64 subtract(double duration)
          Creates a new TimeStamp instance offset from this timestamp by the given amount.
 java.util.Calendar toCalendar()
          Converts this TimeStamp to a Calendar.
 java.util.Date toDate()
          Converts this TimeStamp to a Date.
 long toPosixMicros()
          Converts this TimeStamp to posix microseconds.
 long toPosixMillis()
          Converts this TimeStamp to posix milliseconds.
 long toPosixNanos()
          Converts this TimeStamp to posix nanoseconds.
 double toPosixSeconds()
          Converts this TimeStamp to posix seconds.
 java.math.BigDecimal toPosixSecondsExact()
          Converts this TimeStamp to posix seconds.
 
Methods inherited from class com.metsci.glimpse.util.units.time.TimeStamp
currentTime, fromCalendar, fromDate, fromPosixMicros, fromPosixMillis, fromPosixNanos, fromPosixSeconds, fromPosixSeconds, fromString, fromString, fromTimeStamp, isAfterOrEquals, isBeforeOrEquals, posixEpoch, toString, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

factory

public static final TimeStampFactory<TimeStampPosixMillisInt64> factory
Method Detail

add

public TimeStampPosixMillisInt64 add(double duration)
Description copied from class: TimeStamp
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.

Specified by:
add in class TimeStamp
Parameters:
duration - the amount of time to add in system-units

subtract

public TimeStampPosixMillisInt64 subtract(double duration)
Description copied from class: TimeStamp
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.

Specified by:
subtract in class TimeStamp
Parameters:
duration - the amount of time to subtract in system-units

durationBefore

public double durationBefore(TimeStamp o)
Description copied from class: TimeStamp
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.

Overrides:
durationBefore in class TimeStamp
Returns:
the difference, in system-units

durationAfter

public double durationAfter(TimeStamp o)
Description copied from class: TimeStamp
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.

Overrides:
durationAfter in class TimeStamp
Returns:
the difference, in system-units

toPosixSeconds

public double toPosixSeconds()
Description copied from class: TimeStamp
Converts this TimeStamp to posix seconds.

Specified by:
toPosixSeconds in class TimeStamp
Returns:
seconds since the epoch

toPosixMillis

public long toPosixMillis()
Description copied from class: TimeStamp
Converts this TimeStamp to posix milliseconds.

Specified by:
toPosixMillis in class TimeStamp
Returns:
milliseconds since the epoch

toPosixMicros

public long toPosixMicros()
Description copied from class: TimeStamp
Converts this TimeStamp to posix microseconds.

Specified by:
toPosixMicros in class TimeStamp
Returns:
microseconds since the epoch

toPosixNanos

public long toPosixNanos()
Description copied from class: TimeStamp
Converts this TimeStamp to posix nanoseconds.

Specified by:
toPosixNanos in class TimeStamp
Returns:
nanoseconds since the epoch

toDate

public java.util.Date toDate()
Description copied from class: TimeStamp
Converts this TimeStamp to a Date.

Specified by:
toDate in class TimeStamp

toCalendar

public java.util.Calendar toCalendar()
Description copied from class: TimeStamp
Converts this TimeStamp to a Calendar.

Specified by:
toCalendar in class TimeStamp

toPosixSecondsExact

public java.math.BigDecimal toPosixSecondsExact()
Description copied from class: TimeStamp
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.

Specified by:
toPosixSecondsExact in class TimeStamp
Returns:
seconds since the epoch

isBefore

public boolean isBefore(TimeStamp o)
Description copied from class: TimeStamp
Returns true iff this timestamp is before the given timestamp.

Overrides:
isBefore in class TimeStamp

isAfter

public boolean isAfter(TimeStamp o)
Description copied from class: TimeStamp
Returns true iff this timestamp is after the given timestamp.

Overrides:
isAfter in class TimeStamp

compareTo

public int compareTo(TimeStamp o)
Specified by:
compareTo in interface java.lang.Comparable<TimeStamp>
Overrides:
compareTo in class TimeStamp

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class TimeStamp

hashCode

public int hashCode()
Overrides:
hashCode in class TimeStamp


Copyright © 2012 Metron, Inc.. All Rights Reserved.