org.epics.pvmanager.util
Class TimeDuration

java.lang.Object
  extended by org.epics.pvmanager.util.TimeDuration

public class TimeDuration
extends java.lang.Object

A duration of time (such as 3 sec, 30ms, 1nsec) at the nanosecond precision. The duration is stored a (signed) long, which makes the maximum valid duration to around 292 years. No checks for overflows are done.

Note that while TimeStamp are usually created according to system clocks which takes into account leap seconds, all the math operations on TimeStamps do not take leap seconds into account.

Author:
carcassi

Method Summary
 TimeInterval after(TimeStamp reference)
          Returns a time interval that lasts this duration and starts from the given timestamp.
 TimeInterval around(TimeStamp reference)
          Returns a time interval that lasts this duration and is centered around the given timestamp.
 TimeInterval before(TimeStamp reference)
          Returns a time interval that lasts this duration and ends at the given timestamp.
 TimeDuration divideBy(int factor)
          Returns a new duration which is smaller by the given factor.
 boolean equals(java.lang.Object obj)
           
 long getNanoSec()
          Duration in nanoseconds.
 int hashCode()
           
static TimeDuration ms(int ms)
          A new duration in milliseconds.
 TimeDuration multiplyBy(int factor)
          Returns a new duration which is bigger by the given factor.
static TimeDuration nanos(long nanoSec)
          A new duration in nanoseconds.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getNanoSec

public long getNanoSec()
Duration in nanoseconds.

Returns:
duration in nanoseconds.

ms

public static TimeDuration ms(int ms)
A new duration in milliseconds.

Parameters:
ms - milliseconds of the duration
Returns:
a new duration
Throws:
java.lang.IllegalArgumentException - if the duration is negative

nanos

public static TimeDuration nanos(long nanoSec)
A new duration in nanoseconds.

Parameters:
nanoSec - nanoseconds of the duration
Returns:
a new duration
Throws:
java.lang.IllegalArgumentException - if the duration is negative

divideBy

public TimeDuration divideBy(int factor)
Returns a new duration which is smaller by the given factor.

Parameters:
factor - constant to divide
Returns:
a new duration
Throws:
java.lang.IllegalArgumentException - if factor is negative

multiplyBy

public TimeDuration multiplyBy(int factor)
Returns a new duration which is bigger by the given factor.

Parameters:
factor - constant to multiply
Returns:
a new duration
Throws:
java.lang.IllegalArgumentException - if factor is negative

around

public TimeInterval around(TimeStamp reference)
Returns a time interval that lasts this duration and is centered around the given timestamp.

Parameters:
reference - a timestamp
Returns:
a new time interval

after

public TimeInterval after(TimeStamp reference)
Returns a time interval that lasts this duration and starts from the given timestamp.

Parameters:
reference - a timestamp
Returns:
a new time interval

before

public TimeInterval before(TimeStamp reference)
Returns a time interval that lasts this duration and ends at the given timestamp.

Parameters:
reference - a timestamp
Returns:
a new time interval

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

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


Copyright © 2010. All Rights Reserved.