Package tech.units.indriya.quantity.time
Class TemporalQuantity
- java.lang.Object
-
- tech.units.indriya.AbstractQuantity<Time>
-
- tech.units.indriya.quantity.time.TemporalQuantity
-
- All Implemented Interfaces:
Serializable,Comparable<Quantity<Time>>,Quantity<Time>,ComparableQuantity<Time>,tech.uom.lib.common.function.QuantityConverter<Time>,tech.uom.lib.common.function.UnitSupplier<Time>,tech.uom.lib.common.function.ValueSupplier<Number>
public final class TemporalQuantity extends AbstractQuantity<Time>
Class that representsTemporalUnitin Unit-API- Since:
- 1.0
- Version:
- 1.3, Jun 4, 2019
- Author:
- Werner Keil, Filip van Laenen, Andi Huber
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface javax.measure.Quantity
Quantity.Scale
-
-
Field Summary
-
Fields inherited from class tech.units.indriya.AbstractQuantity
NONE, ONE
-
-
Method Summary
-
Methods inherited from class tech.units.indriya.AbstractQuantity
asType, compareTo, divide, getScale, getUnit, hasFraction, hasFraction, inverse, isEquivalentTo, isGreaterThan, isGreaterThanOrEqualTo, isLessThan, isLessThanOrEqualTo, multiply, parse, to
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface javax.measure.Quantity
toSystemUnit
-
-
-
-
Method Detail
-
of
public static TemporalQuantity of(Number number, TemporalUnit timeUnit)
- Parameters:
value- - value to be usedtimeUnit- - time to be used
-
of
public static TemporalQuantity of(Quantity<Time> quantity)
- Parameters:
quantity- - quantity to be used- Returns:
- the
TemporalQuantityconverted be quantity in seconds.
-
getTemporalAmount
public TemporalAmount getTemporalAmount()
Returns theTemporalAmountof thisTemporalQuantity, which may involve rounding or truncation.- Returns:
- the TemporalAmount
- Throws:
ArithmeticException- when thevalueof thisTemporalQuantitycannot be converted to long
-
getTemporalUnit
public TemporalUnit getTemporalUnit()
get toTemporalUnit- Returns:
- the TemporalUnit
-
toUnit
public Unit<Time> toUnit()
converts theTemporalUnittoUnit- Returns:
- the
getTemporalUnit()converted to Unit
-
toQuantity
public Quantity<Time> toQuantity()
Converts theTemporalQuantitytoQuantity- Returns:
- this class converted to Quantity
-
to
public TemporalQuantity to(TemporalUnit aTimeUnit)
-
hashCode
public int hashCode()
Description copied from class:AbstractQuantityReturns the hash code for this quantity.- Overrides:
hashCodein classAbstractQuantity<Time>- Returns:
- the hash code value.
-
equals
public boolean equals(Object obj)
Description copied from class:AbstractQuantityCompares this quantity against the specified object for strict equality (same unit and same amount).Similarly to the
BigDecimal.equals(java.lang.Object)method which consider 2.0 and 2.00 as different objects because of different internal scales, quantities such asQuantities.getQuantity(3.0, KILOGRAM)Quantities.getQuantity(3, KILOGRAM)andQuantities.getQuantity("3 kg")might not be considered equals because of possible differences in their implementations.To compare quantities stated using different units or using different amount implementations the
compareToorAbstractQuantity.isEquivalentTo(javax.measure.Quantity<Q>)methods should be used.- Overrides:
equalsin classAbstractQuantity<Time>- Parameters:
obj- the object to compare with.- Returns:
this.getUnit.equals(obj.getUnit()) && this.getScale().equals(obj.getScale() && this.getValue().equals(obj.getValue())
-
toString
public String toString()
Description copied from class:AbstractQuantityReturns theStringrepresentation of this quantity. The string produced for a given quantity is always the same; it is not affected by locale. This means that it can be used as a canonical string representation for exchanging quantity, or as a key for a Hashtable, etc. Locale-sensitive quantity formatting and parsing is handled by theQuantityFormatimplementations and its subclasses.- Overrides:
toStringin classAbstractQuantity<Time>- Returns:
SimpleQuantityFormat.getInstance().format(this)
-
add
public ComparableQuantity<Time> add(Quantity<Time> that)
- See Also:
Quantity.add(Quantity)
-
subtract
public ComparableQuantity<Time> subtract(Quantity<Time> that)
- See Also:
Quantity.subtract(Quantity)
-
divide
public ComparableQuantity<?> divide(Quantity<?> that)
- See Also:
Quantity.divide(Quantity)
-
divide
public ComparableQuantity<Time> divide(Number that)
- See Also:
Quantity.divide(Number)
-
multiply
public ComparableQuantity<?> multiply(Quantity<?> that)
- See Also:
Quantity.multiply(Quantity)
-
multiply
public ComparableQuantity<Time> multiply(Number that)
- See Also:
Quantity.multiply(Number)
-
inverse
public ComparableQuantity<Frequency> inverse()
- See Also:
Quantity.inverse()
-
-