public final class Time extends AbstractMeasure<TimeUnit,Time> implements java.time.temporal.TemporalAmount
TimeUnit.
Use values of Time directly in arithmetic expressions with other dimensions such as:
// commonly used unit abbreviations e.g., m, ft, hr, mph, etc.
import static manifold.science.util.UnitConstants.*;
...
Time duration = 5.2 hr;
Time mileTime = 4 min + 12.78 sec;
Length distance = 80 mph * 2.3 hr;
Like all dimensions in the manifold.science.measures library, the Time dimension is unit-independent,
which means you can work with any combination of TimeUnit such as Second, Hour, and
Day, because all operations on Time are maintained internally using standard SI units.
Time seconds = 12.7 s;
seconds = seconds + 5.2 hr; // add hours to seconds
Time implements TemporalAmount so you can easily work with Java's java.time library:
LocalDateTime date = LocalDateTime.of( 2018, 10, 17, 17, 35 );
LocalDateTime yearLater = date + 1 yr;
LocalDateTime tomorrowOneHourLater = date + 1 day + 1 hr;
ComparableUsing.EqualityMode, ComparableUsing.Operator| Constructor and Description |
|---|
Time(Rational value,
TimeUnit unit) |
Time(Rational value,
TimeUnit unit,
TimeUnit displayUnit) |
| Modifier and Type | Method and Description |
|---|---|
java.time.temporal.Temporal |
addTo(java.time.temporal.Temporal temporal) |
long |
get(java.time.temporal.TemporalUnit unit) |
TimeUnit |
getBaseUnit()
The unit on which all instances of this type are based.
|
java.util.List<java.time.temporal.TemporalUnit> |
getUnits() |
Time |
make(Rational value,
TimeUnit unit)
Creates a new instance using the specified parameters.
|
Time |
make(Rational value,
TimeUnit unit,
TimeUnit displayUnit)
Creates a new instance using the specified parameters.
|
static Time |
now() |
java.time.temporal.Temporal |
subtractFrom(java.time.temporal.Temporal temporal) |
Velocity |
times(Acceleration acc) |
Charge |
times(Current current) |
Momentum |
times(Force force) |
Angle |
times(Frequency frequency) |
Energy |
times(Power power) |
Length |
times(Velocity r) |
compareTo, copy, copy, div, equalityMode, equals, fromBaseNumber, fromNumber, getDisplayUnit, getValue, hashCode, minus, nextInSequence, nextNthInSequence, plus, previousInSequence, previousNthInSequence, rem, to, toBaseNumber, toMixedString, toNumber, toNumber, toStringclone, finalize, getClass, jailbreak, notify, notifyAll, wait, wait, waitdiv, rem, times, unaryMinuscompareToUsingpublic TimeUnit getBaseUnit()
AbstractMeasureLength dimension might use Meters
as the base unit because it is the SI standard.getBaseUnit in class AbstractMeasure<TimeUnit,Time>public Time make(Rational value, TimeUnit unit, TimeUnit displayUnit)
AbstractMeasuremake in class AbstractMeasure<TimeUnit,Time>public Time make(Rational value, TimeUnit unit)
AbstractMeasuremake in class AbstractMeasure<TimeUnit,Time>public static Time now()
public long get(java.time.temporal.TemporalUnit unit)
get in interface java.time.temporal.TemporalAmountpublic java.util.List<java.time.temporal.TemporalUnit> getUnits()
getUnits in interface java.time.temporal.TemporalAmountpublic java.time.temporal.Temporal addTo(java.time.temporal.Temporal temporal)
addTo in interface java.time.temporal.TemporalAmountpublic java.time.temporal.Temporal subtractFrom(java.time.temporal.Temporal temporal)
subtractFrom in interface java.time.temporal.TemporalAmountpublic Velocity times(Acceleration acc)
Copyright © 2022. All rights reserved.