|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--net.agmodel.physical.AbstractQuantity
|
+--net.agmodel.physical.Duration
This class represents a period of existence or persistence. It is a modified version of classes from World Builders. (Originals available at http://www.magi.com/~wb/quantity.html)
| Field Summary | |
static Duration |
HALF_HOUR
|
static Duration |
ONE_DAY
|
static Duration |
ONE_HOUR
|
static Duration |
ONE_MILLISECOND
|
static Duration |
ONE_MINUTE
|
static Duration |
ONE_MONTH
|
static Duration |
ONE_SECOND
|
static Duration |
ONE_YEAR
|
static Duration |
QUARTER_HOUR
|
static Duration |
TEN_MINUTES
|
static Duration |
TWELVE_MINUTES
|
| Fields inherited from class net.agmodel.physical.AbstractQuantity |
AMOUNT_OF_SUBSTANCE, COMPLETE, derivation, DEVOID, DIMENSIONLESS, ELECTRIC_CURRENT, LENGTH, LUMINOUS_INTENSITY, MASS, SPATIALLYINTERPOLATED, TEMPORALLYINTERPOLATED, THERMODYNAMIC_TEMPERATURE, TIME, UNINTERPOLATED |
| Constructor Summary | |
Duration()
Creates a default Duration of length 0 |
|
Duration(Composite c)
Duration constructor from Composite quantity. |
|
Duration(Date a,
Date b)
Creates a Duration consisting of the absolute time between two Dates |
|
Duration(double value,
DurationUnit unit)
Duration constructor. |
|
| Method Summary | |
Duration |
add(Duration x)
Returns a Duration whose value is (this + x). |
Date |
addToDate(Date input)
Add this duration onto the input date, and return a new date as the result |
int |
compareTo(Duration x)
Compares this Duration with the specified Duration. |
int |
compareTo(Object o)
Compares this Duration with the specified Object. |
Duration |
divide(double coefficient)
Returns a Duration whose value is (this / coefficient). |
double |
dividedBy(Duration another)
Returns the ratio this/another |
protected int |
getDimensionSI()
Gets the SI dimension of this Duration. |
double |
getValue(DurationUnit unit)
Gets the duration in the specified unit. |
protected double |
getValueSI()
Gets the duration in seconds. |
Frequency |
inverse()
Returns the Frequency corresponding to this duration period. |
static Duration |
lookup(String name)
|
Speed |
multiply(Acceleration a)
Returns a Speed whose value is (this * a). |
Duration |
multiply(double coefficient)
Returns a Duration whose value is (this * coefficient). |
Length |
multiply(Speed s)
Returns a Length whose value is (this * s). |
static Date |
oneWithSameTimeAsTwo(Date date1,
Date date2)
Returns the nearest Date <= date1 with the same "time" as date2 eg if date 1 is 0000 on 1/1/99 and date 2 time is 0900 (date doesn't matter) then returns 0900 on 31/12/98 |
void |
setValue(Date a,
Date b)
Sets this Duration to the absolute time between two Dates |
void |
setValue(double value,
DurationUnit unit)
Sets this Duration using the specified unit. |
Duration |
subtract(Duration x)
Returns a Duration whose value is (this - x). |
Date |
subtractFromDate(Date input)
Subtract this duration from the input date, and return a new date as the result |
String |
toString()
Presents the duration as a string |
| Methods inherited from class net.agmodel.physical.AbstractQuantity |
clone, divide, getSymbolSI, isSpatiallyInterpolated, isTemporallyInterpolated, multiply, toComposite |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final Duration ONE_MILLISECOND
public static final Duration ONE_SECOND
public static final Duration ONE_MINUTE
public static final Duration TEN_MINUTES
public static final Duration TWELVE_MINUTES
public static final Duration QUARTER_HOUR
public static final Duration HALF_HOUR
public static final Duration ONE_HOUR
public static final Duration ONE_DAY
public static final Duration ONE_MONTH
public static final Duration ONE_YEAR
| Constructor Detail |
public Duration(double value,
DurationUnit unit)
value - the duration in the specified unit (>=0).unit - the measurement unit being used.
IllegalArgumentException - if value > 0public Duration(Composite c)
c - the quantity to convert.
UnitDimensionException - composite is not a duration.Composite
public Duration(Date a,
Date b)
a - a Date.b - another Date.public Duration()
| Method Detail |
public static final Date oneWithSameTimeAsTwo(Date date1,
Date date2)
public double getValue(DurationUnit unit)
unit - the measurement unit being used.
ArrayIndexOutOfBoundsException - unknown measurement unit
public void setValue(double value,
DurationUnit unit)
value - the new duration in the specified unit.unit - the measurement unit being used.
ArrayIndexOutOfBoundsException - unknown measurement unit
public void setValue(Date a,
Date b)
a - a Date.b - another Date.public Duration add(Duration x)
x - the Duration to be added.
public Duration subtract(Duration x)
x - the Duration to be subtracted.
public Duration multiply(double coefficient)
coefficient - the dimensionless multiplier.
public Duration divide(double coefficient)
coefficient - the dimensionless divisor.
ArithmeticException - coefficient == 0.0public Length multiply(Speed s)
s - the speed multiplier.
public Speed multiply(Acceleration a)
a - the acceleration multiplier.
public Frequency inverse()
ArithmeticException - this == 0.0 Secondpublic int compareTo(Duration x)
x - Duration to which this Duration is to be compared.
public int compareTo(Object o)
compareTo in interface Comparableo - Object to which this Duration is to be compared.
ClassCastException - o is not a Duration.compareTo(Duration),
Comparableprotected double getValueSI()
getValueSI in class AbstractQuantityprotected int getDimensionSI()
getDimensionSI in class AbstractQuantitypublic Date subtractFromDate(Date input)
public Date addToDate(Date input)
public double dividedBy(Duration another)
public String toString()
toString in class AbstractQuantitypublic static Duration lookup(String name)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||