gov.sandia.cognition.time
Interface Duration

All Superinterfaces:
Comparable<Duration>, Serializable
All Known Implementing Classes:
DefaultDuration

public interface Duration
extends Serializable, Comparable<Duration>

Represents a duration of time. A duration is a standard span of time that does not depend on any specific date or calendar representation. It has methods for getting the standard time components of the span for standard milliseconds (1ms), seconds(1s=1000ms), minutes (1m=60s), hours (1h=60m), and days (1d=24h). Durations can be either positive or negative. The reason this interface exists is that date/time API designs have advanced much beyond the original Java date/time classes. Java may revise these at some point, but we have a need for interfacing with a lot of time-based data, so we have created this interface. In the future, if Java changes its time APIs, those can either be adapted to this interface or this interface could be deprecated. The design of the interface is based on Joda time, .NET TimeSpan, and JavaFX Duration.

Since:
3.0
Author:
Justin Basilico

Method Summary
 Duration absoluteValue()
          Returns the absolute value of this duration.
 Duration divide(double scalar)
          Divides this duration by the given scalar value and returns the result.
 double divide(Duration other)
          Divides this duration by the given duration and returns the ratio.
 boolean equals(Duration other)
          Determines if this duration is equivalent to the given duration.
 long getDaysPart()
          Gets the standard minutes part of the time.
 int getHoursPart()
          Gets the standard hours part of the time.
 int getMillisecondsPart()
          Gets the standard milliseconds part of the time.
 int getMinutesPart()
          Gets the standard minutes part of the time.
 int getSecondsPart()
          Gets the standard seconds part of the time.
 double getTotalDays()
          Gets the total number of standard days of this duration.
 double getTotalHours()
          Gets the total number of standard hours of this duration.
 double getTotalMilliseconds()
          Gets the total number of standard milliseconds of this duration.
 double getTotalMinutes()
          Gets the total number of standard minutes of this duration.
 double getTotalSeconds()
          Gets the total number of standard seconds of this duration.
 Duration minus(Duration other)
          Subtracts the given duration from this duration and returns the difference.
 Duration negative()
          Returns the negative of this duration.
 Duration plus(Duration other)
          Adds this duration to the given duration and returns the sum.
 Duration times(double scalar)
          Multiplies this duration by the given scalar value and returns the product.
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

negative

Duration negative()
Returns the negative of this duration.

Returns:
The negative of this duration.

absoluteValue

Duration absoluteValue()
Returns the absolute value of this duration.

Returns:
The absolute value of this duration.

equals

boolean equals(Duration other)
Determines if this duration is equivalent to the given duration.

Parameters:
other - The other duration.
Returns:
True if this duration is equal to the given duration.

plus

Duration plus(Duration other)
Adds this duration to the given duration and returns the sum.

Parameters:
other - The other duration.
Returns:
The sum of this duration and the other duration.

minus

Duration minus(Duration other)
Subtracts the given duration from this duration and returns the difference.

Parameters:
other - The other duration.
Returns:
The difference of this duration and the other duration.

times

Duration times(double scalar)
Multiplies this duration by the given scalar value and returns the product.

Parameters:
scalar - The scalar value.
Returns:
The product of this duration and the scalar value.

divide

double divide(Duration other)
Divides this duration by the given duration and returns the ratio.

Parameters:
other - The other duration.
Returns:
The result of dividing this duration by the given duration.

divide

Duration divide(double scalar)
Divides this duration by the given scalar value and returns the result.

Parameters:
scalar - The scalar value.
Returns:
The result of dividing this duration by the given scalar value.

getTotalMilliseconds

double getTotalMilliseconds()
Gets the total number of standard milliseconds of this duration.

Returns:
The total number of standard milliseconds.

getTotalSeconds

double getTotalSeconds()
Gets the total number of standard seconds of this duration.

Returns:
The total number of standard seconds.

getTotalMinutes

double getTotalMinutes()
Gets the total number of standard minutes of this duration.

Returns:
The total number of standard minutes.

getTotalHours

double getTotalHours()
Gets the total number of standard hours of this duration.

Returns:
The total number of standard hours.

getTotalDays

double getTotalDays()
Gets the total number of standard days of this duration.

Returns:
The total number of standard days.

getMillisecondsPart

int getMillisecondsPart()
Gets the standard milliseconds part of the time. It is in the range of -999 to 999, inclusive.

Returns:
The standard milliseconds part of the time.

getSecondsPart

int getSecondsPart()
Gets the standard seconds part of the time. It is in the range of -59 to 59, inclusive.

Returns:
The standard seconds part of the time.

getMinutesPart

int getMinutesPart()
Gets the standard minutes part of the time. It is in the range of -59 to 59, inclusive.

Returns:
The standard minutes part of the time.

getHoursPart

int getHoursPart()
Gets the standard hours part of the time. It is in the range of -23 to 23, inclusive.

Returns:
The standard hours part of the time.

getDaysPart

long getDaysPart()
Gets the standard minutes part of the time.

Returns:
The standard minutes part of the time.