com.activequant.domainmodel
Class TimeStamp

java.lang.Object
  extended by com.activequant.domainmodel.TimeStamp
All Implemented Interfaces:
Serializable, Comparable<TimeStamp>

public final class TimeStamp
extends Object
implements Comparable<TimeStamp>, Serializable

Immutable UTC date/time in nanosecond resolution.

- [26.11.2007] Created (Mike Kroutkov)
- [10.10.2009] + Time component getter (Ghost Rider)

Author:
Mike Kroutikov, Ghost Rider
See Also:
Serialized Form

Constructor Summary
TimeStamp()
          Creates new TimeStamp object that corresponds to the current time.
TimeStamp(Date dateValue)
          Creates new TimeStamp object from date's millisecond value, nanosecond part is set to zero.
TimeStamp(Date dateValue, int nanos)
          Creates new TimeStamp object from date's millisecond value, and nanosecond value.
TimeStamp(long value)
          Creates new Timestamp object from nanosecond value.
 
Method Summary
 TimeStamp addDays(long days)
          returns a new time stamp to which days are added.
 int compareTo(TimeStamp other)
           
 boolean equals(Object other)
           
 Date getDate()
           
 long getMilliseconds()
           
 long getNanoseconds()
          Returns time in nanoseconds since Unix epoch (Jan 1, 1970 UTC).
 Time getTimeComponent()
           
 int hashCode()
           
 boolean isAfter(TimeStamp other)
           
 boolean isBefore(TimeStamp other)
           
 boolean isEqual(TimeStamp other)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TimeStamp

public TimeStamp(long value)
Creates new Timestamp object from nanosecond value.

Parameters:
value - nanoseconds since Jan 1, 1970 UTC.

TimeStamp

public TimeStamp(Date dateValue,
                 int nanos)
Creates new TimeStamp object from date's millisecond value, and nanosecond value.

Parameters:
dateValue - date.
nanos - nanosecond part of the timestamp.

TimeStamp

public TimeStamp(Date dateValue)
Creates new TimeStamp object from date's millisecond value, nanosecond part is set to zero.

Parameters:
dateValue - date.

TimeStamp

public TimeStamp()
Creates new TimeStamp object that corresponds to the current time. Note that it is the same as calling
 new TimeStamp(new Date());
 
and therefore provides only millisecond precision (nanosecond part is guaranteed to be zero).

Method Detail

getNanoseconds

public long getNanoseconds()
Returns time in nanoseconds since Unix epoch (Jan 1, 1970 UTC).

Returns:

getMilliseconds

public long getMilliseconds()

getDate

public Date getDate()

hashCode

public int hashCode()
Overrides:
hashCode in class Object

compareTo

public int compareTo(TimeStamp other)
Specified by:
compareTo in interface Comparable<TimeStamp>

equals

public boolean equals(Object other)
Overrides:
equals in class Object

isBefore

public boolean isBefore(TimeStamp other)

isAfter

public boolean isAfter(TimeStamp other)

isEqual

public boolean isEqual(TimeStamp other)

toString

public String toString()
Overrides:
toString in class Object

getTimeComponent

public Time getTimeComponent()

addDays

public TimeStamp addDays(long days)
returns a new time stamp to which days are added.

Parameters:
days -
Returns:


Copyright © 2012 ActiveQuant GmbH. All Rights Reserved.