Top Description Fields Constructors Methods
tech.units.indriya.quantity.time

public final Class TimeUnitQuantity

extends AbstractQuantity<Time>
Class Inheritance
Static Imports
tech.units.indriya.unit.Units.DAY, .Units.HOUR, .Units.MINUTE, .Units.SECOND

Class that represents TimeUnit in Unit-API
Authors
Otavio Santana, Werner Keil, Andi Huber
Since
1.0
Version
1.2

Field Summary

Modifier and TypeField and Description
private static final long
private final TimeUnit
private final Number
Inherited from tech.units.indriya.AbstractQuantity:
NONEONE

Constructor Summary

AccessConstructor and Description
pack-priv
TimeUnitQuantity(TimeUnit
- time to be used
timeUnit
,
Number
- value to be used
value
)

creates the TimeUnitQuantity using TimeUnit and Long

Method Summary

Modifier and TypeMethod and Description
public ComparableQuantity<Time>
add(Quantity<Time>
the Quantity to be added.
that
)

Implements tech.units.indriya.ComparableQuantity.add.

Returns the sum of this Quantity with the one specified.

private ComparableQuantity<Time>
private ComparableQuantity<?>
private static <R extends Quantity<R>> Number
public ComparableQuantity<?>
divide(Quantity<?>
the Quantity divisor.
that
)

Implements tech.units.indriya.ComparableQuantity.divide.

Returns the quotient of this Quantity divided by the Quantity specified.

public ComparableQuantity<Time>
divide(Number
the Number divisor.
that
)

Implements tech.units.indriya.ComparableQuantity.divide.

Returns the quotient of this Quantity divided by the Number specified.

public boolean
equals(Object
the object to compare with.
obj
)

Overrides tech.units.indriya.AbstractQuantity.equals.

Compares this quantity against the specified object for strict equality (same unit and same amount).

public TimeUnit

Returns:

the TimeUnit
getTimeUnit
()

get to TimeUnit

public Number
public int
hashCode()

Overrides tech.units.indriya.AbstractQuantity.hashCode.

Returns the hash code for this quantity.

public ComparableQuantity<Frequency>
inverse()

Implements tech.units.indriya.ComparableQuantity.inverse.

Returns a Quantity that is the multiplicative inverse of this Quantity, having reciprocal value and reciprocal unit as given by this.getUnit().inverse().

public ComparableQuantity<?>
multiply(Quantity<?>
the Quantity multiplicand.
that
)

Implements tech.units.indriya.ComparableQuantity.multiply.

Returns the product of this Quantity with the one specified.

public ComparableQuantity<Time>
multiply(Number
the Number multiplicand.
that
)

Implements tech.units.indriya.ComparableQuantity.multiply.

Returns the product of this Quantity with the Number value specified.

public Quantity<Time>
negate()

Implements javax.measure.Quantity.negate.

Returns a Quantity whose value is (-this.getValue()).

public static TimeUnitQuantity
of(Number number, TimeUnit
- time to be used
timeUnit
)

creates the TimeUnitQuantity using TimeUnit and Long

public static TimeUnitQuantity

Returns:

the TimeUnitQuantity converted be quantity in seconds.
of
(Quantity<Time>
- quantity to be used
quantity
)

Creates a TimeUnitQuantity based a Quantity<Time> converted to SI#SECOND.

private static <R extends Quantity<R>> Number
public ComparableQuantity<Time>
subtract(Quantity<Time>
the Quantity to be subtracted.
that
)

Implements tech.units.indriya.ComparableQuantity.subtract.

Returns the difference between this Quantity and the one specified.

public TimeUnitQuantity
to(TimeUnit aTimeUnit)

public Quantity<Time>

Returns:

this class converted to Quantity
toQuantity
()

Converts the TimeUnitQuantity to Quantity<Time>

public String
toString()

Overrides tech.units.indriya.AbstractQuantity.toString.

Returns the String representation of this quantity.

public Unit<Time>

Returns:

the TimeUnitQuantity#getTimeUnit() converted to Unit
toUnit
()

converts the TimeUnit to Unit

private static Unit<Time>
toUnit(TimeUnit timeUnit)

Inherited from tech.units.indriya.AbstractQuantity:
asTypecompareTodividegetScalegetUnithasFractionhasFractioninverseisEquivalentToisGreaterThanisGreaterThanOrEqualToisLessThanisLessThanOrEqualTomultiplyparseto

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides tech.units.indriya.AbstractQuantity.serialVersionUID.

timeUnitback to summary
private final TimeUnit timeUnit
valueback to summary
private final Number value

Constructor Detail

TimeUnitQuantityback to summary
pack-priv TimeUnitQuantity(TimeUnit timeUnit, Number value)

creates the TimeUnitQuantity using TimeUnit and Long

Parameters
timeUnit:TimeUnit

- time to be used

value:Number

- value to be used

Method Detail

addback to summary
public ComparableQuantity<Time> add(Quantity<Time> that)

Implements tech.units.indriya.ComparableQuantity.add.

Doc from javax.measure.Quantity.add.

Returns the sum of this Quantity with the one specified. The result shall be as if this quantity and the given addend were converted to system unit before to be added, and the result converted back to the unit of this quantity or any other compatible unit at implementation choice.

Parameters
that:Quantity<Time>

the Quantity to be added.

Returns:ComparableQuantity<Time>

this + addend.

Annotations
@Override
Since
1.0.1
applyMultiplicativeNumberOperationback to summary
private ComparableQuantity<Time> applyMultiplicativeNumberOperation(Number that, BinaryOperator<Number> valueOperator)
applyMultiplicativeQuantityOperationback to summary
private ComparableQuantity<?> applyMultiplicativeQuantityOperation(Quantity<?> that, BinaryOperator<Number> valueOperator, BinaryOperator<Unit<?>> unitOperator)
convertedQuantityValueback to summary
private static <R extends Quantity<R>> Number convertedQuantityValue(Quantity<R> that, Unit<R> unit)
divideback to summary
public ComparableQuantity<?> divide(Quantity<?> that)

Implements tech.units.indriya.ComparableQuantity.divide.

Doc from javax.measure.Quantity.divide.

Returns the quotient of this Quantity divided by the Quantity specified. The result shall be as if this quantity and the given divisor were converted to system unit before to be divided, and the result converted back to the unit of this quantity or any other compatible unit at implementation choice.

Parameters
that:Quantity<?>

the Quantity divisor.

Returns:ComparableQuantity<?>

this / divisor.

Annotations
@Override
Since
1.0.1
divideback to summary
public ComparableQuantity<Time> divide(Number that)

Implements tech.units.indriya.ComparableQuantity.divide.

Doc from javax.measure.Quantity.divide.

Returns the quotient of this Quantity divided by the Number specified. The result shall be as if this quantity was converted to system unit before to be divided, and the result converted back to the unit of this quantity or any other compatible unit at implementation choice.

Parameters
that:Number

the Number divisor.

Returns:ComparableQuantity<Time>

this / divisor.

Annotations
@Override
Since
1.0.1
equalsback to summary
public boolean equals(Object obj)

Overrides tech.units.indriya.AbstractQuantity.equals.

Doc from tech.units.indriya.AbstractQuantity.equals.

Compares this quantity against the specified object for strict equality (same unit and same amount).

Similarly to the BigDecimal#equals method which consider 2.0 and 2.00 as different objects because of different internal scales, quantities such as Quantities.getQuantity(3.0, KILOGRAM) Quantities.getQuantity(3, KILOGRAM) and Quantities.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 compareTo or isEquivalentTo methods should be used.

Parameters
obj:Object

the object to compare with.

Returns:boolean

this.getUnit.equals(obj.getUnit()) && this.getScale().equals(obj.getScale() && this.getValue().equals(obj.getValue())

Annotations
@Override
Since
1.0
getTimeUnitback to summary
public TimeUnit getTimeUnit()

get to TimeUnit

Returns:TimeUnit

the TimeUnit

Since
1.0
getValueback to summary
public Number getValue()

Implements abstract tech.units.indriya.AbstractQuantity.getValue.

Implements javax.measure.Quantity.getValue, tech.uom.lib.common.function.ValueSupplier.getValue.

get value expressed in Number

Returns:Number

the value

Since
1.0
hashCodeback to summary
public int hashCode()

Overrides tech.units.indriya.AbstractQuantity.hashCode.

Doc from tech.units.indriya.AbstractQuantity.hashCode.

Returns the hash code for this quantity.

Returns:int

the hash code value.

Annotations
@Override
Since
1.0
inverseback to summary
public ComparableQuantity<Frequency> inverse()

Implements tech.units.indriya.ComparableQuantity.inverse.

Doc from javax.measure.Quantity.inverse.

Returns a Quantity that is the multiplicative inverse of this Quantity, having reciprocal value and reciprocal unit as given by this.getUnit().inverse().

Returns:ComparableQuantity<Frequency>

reciprocal Quantity

Annotations
@Override
Since
1.0.1
multiplyback to summary
public ComparableQuantity<?> multiply(Quantity<?> that)

Implements tech.units.indriya.ComparableQuantity.multiply.

Doc from javax.measure.Quantity.multiply.

Returns the product of this Quantity with the one specified. The result shall be as if this quantity and the given multiplicand were converted to system unit before to be multiplied, and the result converted back to the unit of this quantity or any other compatible unit at implementation choice.

Parameters
that:Quantity<?>

the Quantity multiplicand.

Returns:ComparableQuantity<?>

this * multiplicand.

Annotations
@Override
Since
1.0.1
multiplyback to summary
public ComparableQuantity<Time> multiply(Number that)

Implements tech.units.indriya.ComparableQuantity.multiply.

Doc from javax.measure.Quantity.multiply.

Returns the product of this Quantity with the Number value specified. The result shall be as if this quantity was converted to system unit before to be multiplied, and the result converted back to the unit of this quantity or any other compatible unit at implementation choice.

Parameters
that:Number

the Number multiplicand.

Returns:ComparableQuantity<Time>

this * multiplicand.

Annotations
@Override
Since
1.0.1
negateback to summary
public Quantity<Time> negate()

Implements javax.measure.Quantity.negate.

Doc from javax.measure.Quantity.negate.

Returns a Quantity whose value is (-this.getValue()).

Returns:Quantity<Time>

-this.

Annotations
@Override
Since
1.0.2
ofback to summary
public static TimeUnitQuantity of(Number number, TimeUnit timeUnit)

creates the TimeUnitQuantity using TimeUnit and Long

Parameters
timeUnit:TimeUnit

- time to be used

Since
1.0.9
ofback to summary
public static TimeUnitQuantity of(Quantity<Time> quantity)

Creates a TimeUnitQuantity based a Quantity<Time> converted to SI#SECOND.

Parameters
quantity:Quantity<Time>

- quantity to be used

Returns:TimeUnitQuantity

the TimeUnitQuantity converted be quantity in seconds.

Since
1.0
quantityValueback to summary
private static <R extends Quantity<R>> Number quantityValue(Quantity<R> that)
subtractback to summary
public ComparableQuantity<Time> subtract(Quantity<Time> that)

Implements tech.units.indriya.ComparableQuantity.subtract.

Doc from javax.measure.Quantity.subtract.

Returns the difference between this Quantity and the one specified. The result shall be as if this quantity and the given subtrahend were converted to system unit before to be subtracted, and the result converted back to the unit of this quantity or any other compatible unit at implementation choice.

Parameters
that:Quantity<Time>

the Quantity to be subtracted.

Returns:ComparableQuantity<Time>

this - subtrahend.

Annotations
@Override
Since
1.0.1
toback to summary
public TimeUnitQuantity to(TimeUnit aTimeUnit)
toQuantityback to summary
public Quantity<Time> toQuantity()

Converts the TimeUnitQuantity to Quantity<Time>

Returns:Quantity<Time>

this class converted to Quantity

Since
1.0
toStringback to summary
public String toString()

Overrides tech.units.indriya.AbstractQuantity.toString.

Doc from tech.units.indriya.AbstractQuantity.toString.

Returns the String representation 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 the QuantityFormat implementations and its subclasses.

Returns:String

SimpleQuantityFormat.getInstance().format(this)

Annotations
@Override
toUnitback to summary
public Unit<Time> toUnit()

converts the TimeUnit to Unit

Returns:Unit<Time>

the TimeUnitQuantity#getTimeUnit() converted to Unit

Since
1.0
toUnitback to summary
private static Unit<Time> toUnit(TimeUnit timeUnit)