com.pcauto.util
Class ElapsedTime

java.lang.Object
  extended bycom.pcauto.util.Quantity
      extended bycom.pcauto.util.ElapsedTime
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable

public class ElapsedTime
extends Quantity

ElapsedTime is used to store ElapsedTime quantities. ElapsedTime objects may be instantiated using the ElapsedTimeFormat class, or the ElapsedTime constructor which is the difference of two input dates.

A set of arithmetic operations exists in order to compare, add and subtract ElapsedTime objects. All arithmetic operations have been designed to be null safe.

See Also:
Serialized Form

Field Summary
static ElapsedTime ZERO
          Instance of ElapsedTime with zero value.
 
Fields inherited from class com.pcauto.util.Quantity
quantity, unit
 
Constructor Summary
  ElapsedTime(java.util.Date start, java.util.Date end)
          Creates new ElapsedTime as a difference between start and end dates
protected ElapsedTime(double quantity)
          Creates new ElapsedTime with initial value of supplied BigDecimal.
 
Method Summary
 ElapsedTime add(ElapsedTime quant)
          Adds this ElapsedTime to the supplied ElapsedTime.
static ElapsedTime add(ElapsedTime a, ElapsedTime b)
          Adds supplied ElapsedTime to other supplied ElapsedTime.
static boolean areEqual(ElapsedTime quant1, ElapsedTime quant2)
          Determines if two supplied ElapsedTime objects are equal.
 java.lang.Object clone()
          Creates new ElapsedTime identical to this ElaspedTime.
 int compareTo(ElapsedTime quant)
          Compares this ElapsedTime to the specified ElapsedTime.
 boolean equals(ElapsedTime quant)
          Compares this ElapsedTime to the specified ElapsedTime.
 boolean greaterThan(ElapsedTime quant)
          Compares this ElapsedTime to the specified ElapsedTime.
 boolean lessThan(ElapsedTime quant)
          Compares this ElapsedTime to the specified ElapsedTime.
 ElapsedTime subtract(ElapsedTime quant)
          Subtracts this ElapsedTime from supplied ElapsedTime.
 java.lang.String toString()
          Returns String representation of quantity of ElapsedTime object.
 
Methods inherited from class com.pcauto.util.Quantity
add, add, areEqual, compareTo, compareTo, divide, equals, equals, getQuantity, getUnit, greaterThan, lessThan, myDivide, myMultiply, setQuantity, setUnit, setZERO, subtract
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO

public static final ElapsedTime ZERO
Instance of ElapsedTime with zero value.

Constructor Detail

ElapsedTime

protected ElapsedTime(double quantity)
Creates new ElapsedTime with initial value of supplied BigDecimal.

Parameters:
quantity - BigDecimal

ElapsedTime

public ElapsedTime(java.util.Date start,
                   java.util.Date end)
Creates new ElapsedTime as a difference between start and end dates

Parameters:
start - Date
end - Date
Method Detail

clone

public java.lang.Object clone()
Creates new ElapsedTime identical to this ElaspedTime.

Specified by:
clone in class Quantity
Returns:
new ElapsedTime object

equals

public boolean equals(ElapsedTime quant)
Compares this ElapsedTime to the specified ElapsedTime. The result is true if and only if the argument is not null and is a ElapsedTime object that has the same value. Different scales for the same value will return false (e.g. 2.00 equals 2 returns false).

Returns:
true if times are equivalent; false othewise.

compareTo

public int compareTo(ElapsedTime quant)
Compares this ElapsedTime to the specified ElapsedTime. Different scales for the same value will return 0 (e.g. 2.00 compareTo 2 returns 0).

Returns:
0 if they are equal. 1 if this ElapsedTime is larger. -1 if this ElapsedTime is smaller.

greaterThan

public boolean greaterThan(ElapsedTime quant)
Compares this ElapsedTime to the specified ElapsedTime.

Returns:
true if this is greater than elt; false otherwise

lessThan

public boolean lessThan(ElapsedTime quant)
Compares this ElapsedTime to the specified ElapsedTime.

Returns:
true if this is less than elt; false otherwise

areEqual

public static boolean areEqual(ElapsedTime quant1,
                               ElapsedTime quant2)
Determines if two supplied ElapsedTime objects are equal. null safe. Different scales for the same value will return false (e.g. 2.00 areEqual 2 returns false).

Returns:
true if equal, false otherwise

add

public ElapsedTime add(ElapsedTime quant)
Adds this ElapsedTime to the supplied ElapsedTime. null parameter is considered equal to ElapsedTime with zero quantity.

Returns:
ElapsedTime object resulting from addition operation

add

public static ElapsedTime add(ElapsedTime a,
                              ElapsedTime b)
Adds supplied ElapsedTime to other supplied ElapsedTime. null parameter is considered equal to ZERO ElapsedTime zero quantity.

Parameters:
a - first ElapsedTime object
b - second ElapsedTime object
Returns:
ElapsedTime object resulting from addition of a and b

subtract

public ElapsedTime subtract(ElapsedTime quant)
Subtracts this ElapsedTime from supplied ElapsedTime. null parameter is considered equal to ElapsedTime with zero quantity.

Returns:
ElapsedTime object resulting from subtraction operation

toString

public java.lang.String toString()
Returns String representation of quantity of ElapsedTime object.

Returns:
String