de.unkrig.commons.util.time
Class Duration

java.lang.Object
  extended by de.unkrig.commons.util.time.Duration

public final class Duration
extends java.lang.Object

Representation of the length of time between two points of time, with a resolution of 1 millisecond.


Constructor Summary
Duration(double seconds)
           
Duration(long ms)
           
Duration(java.lang.String s)
           
 
Method Summary
 Duration add(Duration other)
           
 Duration divide(double divisor)
           
 boolean equals(java.lang.Object obj)
           
 int hashCode()
           
 boolean isZero()
           
 long milliseconds()
           
 Duration multiply(double factor)
           
 double toSeconds()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Duration

public Duration(long ms)

Duration

public Duration(double seconds)

Duration

public Duration(java.lang.String s)
Method Detail

milliseconds

public long milliseconds()
Returns:
The number of milliseconds represented by this object

toSeconds

public double toSeconds()
Returns:
The length of time in seconds represented by this object

toString

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

add

public Duration add(Duration other)
Returns:
A duration that represents the sum of this and other

multiply

public Duration multiply(double factor)
Returns:
A duration that is factor as long as this duration

divide

public Duration divide(double divisor)
Returns:
A duration which is one divisorth of this duration long

isZero

public boolean isZero()
Returns:
Whether this object represents the zero-length interval

hashCode

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

equals

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