Package com.irurueta.units
Class Time
- All Implemented Interfaces:
Serializable
Contains a time value and unit.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds provided time value and unit and updates current time instance.static doubleAdds two time values and units and returns the result.voidAdds provided time and updates current time instance.voidAdds provided time and stores the result into provided time instance.static voidAdds two time instances and stores the result into provided instance.voidAdds provided time value and unit and updates current time instance.static NumberAdds two time values and units and returns the result.addAndReturnNew(double value, TimeUnit unit, TimeUnit resultUnit) Adds provided time value and unit and returns a new time instance using provided unit.static TimeaddAndReturnNew(Time arg1, Time arg2, TimeUnit unit) Adds two time instances.addAndReturnNew(Time t, TimeUnit unit) Adds provided time to current instance and returns a new time instance.addAndReturnNew(Number value, TimeUnit unit, TimeUnit resultUnit) Adds provided time value and unit and returns a new time instance using provided unit.booleanequals(Measurement<TimeUnit> other, double tolerance) Determines if two time instances are equal up to a certain tolerance.voidSubtracts provided time value and unit and updates current time instance.static doubleSubtracts two time values and units and returns the result.voidSubtract provided time and updates current time.voidSubtracts provided time and stores the result into provided time.static voidSubtracts two time instances and stores the result into provided instance.voidSubtracts provided time value and unit and updates current time instance.static NumberSubtracts two time values and units and returns the result.subtractAndReturnNew(double value, TimeUnit unit, TimeUnit resultUnit) Subtracts provided time value and unit and returns a new time instance using provided unit.static TimesubtractAndReturnNew(Time arg1, Time arg2, TimeUnit unit) Subtracts two time instances.subtractAndReturnNew(Time t, TimeUnit unit) Subtracts provided time to current instance and returns a new instance.subtractAndReturnNew(Number value, TimeUnit unit, TimeUnit resultUnit) Subtracts provided time value and unit and returns a new time instance using provided unit.
-
Constructor Details
-
Time
Constructor with value and unit.- Parameters:
value- time value.unit- unit of distance.- Throws:
IllegalArgumentException- if either value or unit is null.
-
Time
Time()Constructor.
-
-
Method Details
-
equals
Determines if two time instances are equal up to a certain tolerance. If needed, this method attempts unit conversion to compare both objects.- Overrides:
equalsin classMeasurement<TimeUnit>- Parameters:
other- another time to compare.tolerance- amount of tolerance to determine whether two time instances are equal or not.- Returns:
- true if provided time is assumed to be equal to this instance, false otherwise.
-
add
public static double add(double value1, TimeUnit unit1, double value2, TimeUnit unit2, TimeUnit resultUnit) Adds two time values and units and returns the result.- Parameters:
value1- 1st argument value.unit1- 1st argument unit.value2- 2nd argument value.unit2- 2nd argument unit.resultUnit- unit of result to be returned.- Returns:
- result of addition.
-
add
public static Number add(Number value1, TimeUnit unit1, Number value2, TimeUnit unit2, TimeUnit resultUnit) Adds two time values and units and returns the result.- Parameters:
value1- 1st argument value.unit1- 1st argument unit.value2- 2nd argument value.unit2- 2nd argument unit.resultUnit- unit of result to be returned.- Returns:
- result of addition.
-
add
Adds two time instances and stores the result into provided instance.- Parameters:
arg1- 1st argument.arg2- 2nd argument.result- instance where result will be stored.
-
addAndReturnNew
Adds two time instances.- Parameters:
arg1- 1st argument.arg2- 2nd argument.unit- unit of returned time.- Returns:
- a new instance containing result.
-
addAndReturnNew
Adds provided time value and unit and returns a new time instance using provided unit.- Parameters:
value- value to be added.unit- unit of value to be added.resultUnit- unit of returned time.- Returns:
- a new time containing result.
-
addAndReturnNew
Adds provided time value and unit and returns a new time instance using provided unit.- Parameters:
value- value to be added.unit- unit of value to be added.resultUnit- unit of returned time.- Returns:
- a new time containing result.
-
addAndReturnNew
Adds provided time to current instance and returns a new time instance.- Parameters:
t- time to be added.unit- unit of returned time.- Returns:
- a new time containing result.
-
add
Adds provided time value and unit and updates current time instance.- Parameters:
value- time value to be added.unit- unit of time value.
-
add
Adds provided time value and unit and updates current time instance.- Parameters:
value- time value to be added.unit- unit of time value.
-
add
Adds provided time and updates current time instance.- Parameters:
time- time to be added.
-
add
Adds provided time and stores the result into provided time instance.- Parameters:
t- time to be added.result- instance where result will be stored.
-
subtract
public static double subtract(double value1, TimeUnit unit1, double value2, TimeUnit unit2, TimeUnit resultUnit) Subtracts two time values and units and returns the result.- Parameters:
value1- 1st argument value.unit1- 1st argument unit.value2- 2nd argument value.unit2- 2nd argument unit.resultUnit- unit of result to be returned.- Returns:
- result of subtraction.
-
subtract
public static Number subtract(Number value1, TimeUnit unit1, Number value2, TimeUnit unit2, TimeUnit resultUnit) Subtracts two time values and units and returns the result.- Parameters:
value1- 1st argument value.unit1- 1st argument unit.value2- 2nd argument value.unit2- 2nd argument unit.resultUnit- unit of result to be returned.- Returns:
- result of subtraction.
-
subtract
Subtracts two time instances and stores the result into provided instance.- Parameters:
arg1- 1st argument.arg2- 2nd argument.result- instance where result will be stored.
-
subtractAndReturnNew
Subtracts two time instances.- Parameters:
arg1- 1st argument.arg2- 2nd argument.unit- unit of returned time.- Returns:
- a new instance containing result.
-
subtractAndReturnNew
Subtracts provided time value and unit and returns a new time instance using provided unit.- Parameters:
value- value to be subtracted.unit- unit of value to be subtracted.resultUnit- unit of returned time.- Returns:
- a new time containing result.
-
subtractAndReturnNew
Subtracts provided time value and unit and returns a new time instance using provided unit.- Parameters:
value- value to be subtracted.unit- unit of value to be subtracted.resultUnit- unit of returned time.- Returns:
- a new time containing result.
-
subtractAndReturnNew
Subtracts provided time to current instance and returns a new instance.- Parameters:
t- time to be subtracted.unit- unit of returned time.- Returns:
- a new time containing result.
-
subtract
Subtracts provided time value and unit and updates current time instance.- Parameters:
value- time value to be subtracted.unit- unit of time value.
-
subtract
Subtracts provided time value and unit and updates current time instance.- Parameters:
value- time value to be subtracted.unit- unit of time value.
-
subtract
Subtract provided time and updates current time.- Parameters:
time- time to be subtracted.
-
subtract
Subtracts provided time and stores the result into provided time.- Parameters:
t- time to be subtracted.result- instance where result will be stored.
-