Package tech.units.indriya.quantity.time
Class TemporalQuantity
- java.lang.Object
-
- tech.units.indriya.AbstractQuantity<javax.measure.quantity.Time>
-
- tech.units.indriya.quantity.time.TemporalQuantity
-
- All Implemented Interfaces:
Serializable,Comparable<javax.measure.Quantity<javax.measure.quantity.Time>>,javax.measure.Quantity<javax.measure.quantity.Time>,ComparableQuantity<javax.measure.quantity.Time>,tech.uom.lib.common.function.QuantityConverter<javax.measure.quantity.Time>,tech.uom.lib.common.function.UnitSupplier<javax.measure.quantity.Time>,tech.uom.lib.common.function.ValueSupplier<Number>
public final class TemporalQuantity extends AbstractQuantity<javax.measure.quantity.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
-
-
Field Summary
-
Fields inherited from class tech.units.indriya.AbstractQuantity
NONE, ONE
-
-
Method Summary
Modifier and Type Method Description ComparableQuantity<javax.measure.quantity.Time>add(javax.measure.Quantity<javax.measure.quantity.Time> that)ComparableQuantity<javax.measure.quantity.Time>divide(Number that)ComparableQuantity<?>divide(javax.measure.Quantity<?> that)booleanequals(Object obj)Compares this quantity against the specified object for strict equality (same unit and same amount).TemporalAmountgetTemporalAmount()Returns theTemporalAmountof thisTemporalQuantity, which may involve rounding or truncation.TemporalUnitgetTemporalUnit()get toTemporalUnitNumbergetValue()get value expressed inNumberinthashCode()Returns the hash code for this quantity.ComparableQuantity<javax.measure.quantity.Frequency>inverse()ComparableQuantity<javax.measure.quantity.Time>multiply(Number that)ComparableQuantity<?>multiply(javax.measure.Quantity<?> that)javax.measure.Quantity<javax.measure.quantity.Time>negate()static TemporalQuantityof(Number number, TemporalUnit timeUnit)static TemporalQuantityof(javax.measure.Quantity<javax.measure.quantity.Time> quantity)ComparableQuantity<javax.measure.quantity.Time>subtract(javax.measure.Quantity<javax.measure.quantity.Time> that)TemporalQuantityto(TemporalUnit aTimeUnit)javax.measure.Quantity<javax.measure.quantity.Time>toQuantity()Converts theTemporalQuantitytoQuantityStringtoString()Returns theStringrepresentation of this quantity.javax.measure.Unit<javax.measure.quantity.Time>toUnit()converts theTemporalUnittoUnit-
Methods inherited from class tech.units.indriya.AbstractQuantity
asType, compareTo, divide, getScale, getUnit, hasFraction, hasFraction, inverse, isEquivalentTo, isGreaterThan, isGreaterThanOrEqualTo, isLessThan, isLessThanOrEqualTo, multiply, numberSystem, parse, to
-
-
-
-
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(javax.measure.Quantity<javax.measure.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
-
getValue
public Number getValue()
get value expressed inNumber- Specified by:
getValuein interfacejavax.measure.Quantity<javax.measure.quantity.Time>- Specified by:
getValuein interfacetech.uom.lib.common.function.ValueSupplier<Number>- Specified by:
getValuein classAbstractQuantity<javax.measure.quantity.Time>- Returns:
- the value
-
toUnit
public javax.measure.Unit<javax.measure.quantity.Time> toUnit()
converts theTemporalUnittoUnit- Returns:
- the
getTemporalUnit()converted to Unit
-
toQuantity
public javax.measure.Quantity<javax.measure.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<javax.measure.quantity.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
compareToorequals(Quantity, epsilon, epsilonUnit)methods should be used.- Overrides:
equalsin classAbstractQuantity<javax.measure.quantity.Time>- Parameters:
obj- the object to compare with.- Returns:
this.getUnit.equals(obj.getUnit()) && this.getLevel().equals(obj.getLevel() && 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<javax.measure.quantity.Time>- Returns:
SimpleQuantityFormat.getInstance().format(this)
-
add
public ComparableQuantity<javax.measure.quantity.Time> add(javax.measure.Quantity<javax.measure.quantity.Time> that)
- See Also:
Quantity.add(Quantity)
-
subtract
public ComparableQuantity<javax.measure.quantity.Time> subtract(javax.measure.Quantity<javax.measure.quantity.Time> that)
- See Also:
Quantity.subtract(Quantity)
-
divide
public ComparableQuantity<?> divide(javax.measure.Quantity<?> that)
- See Also:
Quantity.divide(Quantity)
-
divide
public ComparableQuantity<javax.measure.quantity.Time> divide(Number that)
- See Also:
Quantity.divide(Number)
-
multiply
public ComparableQuantity<?> multiply(javax.measure.Quantity<?> that)
- See Also:
Quantity.multiply(Quantity)
-
multiply
public ComparableQuantity<javax.measure.quantity.Time> multiply(Number that)
- See Also:
Quantity.multiply(Number)
-
inverse
public ComparableQuantity<javax.measure.quantity.Frequency> inverse()
- See Also:
Quantity.inverse()
-
negate
public javax.measure.Quantity<javax.measure.quantity.Time> negate()
- Since:
- 1.0.2
-
-