java.lang.Object
com.telenav.kivakit.interfaces.time.Nanoseconds
- All Implemented Interfaces:
Comparable<Nanoseconds>
Accurate model of a number of nanoseconds, represented as a number of seconds and a number of nanoseconds. This
yields the same precision is the same as in Java time.
- Author:
- jonathanl (shibo)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic Nanoseconds
One nanosecondstatic Nanoseconds
One nanosecondstatic Nanoseconds
Zero nanoseconds -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionConverts this count of nanoseconds to aBigDecimal
valuedouble
asDouble()
This number of nanoseconds as a double-precision floating point valueint
compareTo
(Nanoseconds that) dividedBy
(double divisor) Divides this number of nanoseconds by the given divisordouble
dividedBy
(Nanoseconds divisor) Computes this value divided by the given valueboolean
int
hashCode()
boolean
isGreaterThan
(Nanoseconds that) boolean
boolean
isLessThan
(Nanoseconds that) boolean
boolean
boolean
isZero()
static Nanoseconds
milliseconds
(double milliseconds) Factory methodminus
(Nanoseconds that) Computes this minus thatmodulo
(Nanoseconds divisor) Computes the remainder when dividing by the given divisorstatic Nanoseconds
nanoseconds
(double nanoseconds) Factory methodstatic Nanoseconds
nanoseconds
(long nanoseconds) Factory methodstatic Nanoseconds
nanoseconds
(long seconds, long nanoseconds) Factory method that constructs from a number of seconds and a number of nanoseconds.static Nanoseconds
nanoseconds
(BigDecimal nanoseconds) Factory methodplus
(Nanoseconds that) Adds the given number of nanoseconds to this valueroundDown
(Nanoseconds unit) Rounds this value down to the nearest unit valueroundUp
(Nanoseconds unit) Rounds this value up to the nearest unit valuestatic Nanoseconds
seconds
(double seconds) Factory method that constructs from a number of secondstimes
(double factor) Multiplies this number of nanoseconds by the given factortoString()
-
Field Details
-
ZERO
Zero nanoseconds -
ONE
One nanosecond -
ONE_SECOND
One nanosecond
-
-
Constructor Details
-
Nanoseconds
protected Nanoseconds()For serialization
-
-
Method Details
-
milliseconds
Factory method- Parameters:
milliseconds
- The number of nanoseconds- Returns:
- The new
Nanoseconds
object
-
nanoseconds
Factory method- Parameters:
nanoseconds
- The number of nanoseconds- Returns:
- The new
Nanoseconds
object
-
nanoseconds
Factory method- Parameters:
nanoseconds
- The number of nanoseconds- Returns:
- The new
Nanoseconds
object
-
nanoseconds
Factory method- Parameters:
nanoseconds
- The number of nanoseconds- Returns:
- The new
Nanoseconds
object
-
nanoseconds
Factory method that constructs from a number of seconds and a number of nanoseconds. If the nanoseconds value is larger than 1E9, any excess seconds are moved into the seconds value.- Parameters:
seconds
- The number of secondsnanoseconds
- The number of nanoseconds, which may be large enough to include seconds- Returns:
- The new
Nanoseconds
object
-
seconds
Factory method that constructs from a number of seconds- Parameters:
seconds
- The number of seconds- Returns:
- The new
Nanoseconds
object
-
asBigDecimal
Converts this count of nanoseconds to aBigDecimal
value- Returns:
- The number of nanoseconds
-
asDouble
public double asDouble()This number of nanoseconds as a double-precision floating point value- Returns:
- The number of nanoseconds
-
dividedBy
Divides this number of nanoseconds by the given divisor- Parameters:
divisor
- The scaling factor- Returns:
- This number of nanoseconds scaled by the given factor
-
equals
-
hashCode
public int hashCode() -
isNegative
public boolean isNegative() -
isZero
public boolean isZero()- Returns:
- True if this is zero nanoseconds
-
times
Multiplies this number of nanoseconds by the given factor- Parameters:
factor
- The scaling factor- Returns:
- This number of nanoseconds scaled by the given factor
-
toString
-