public final class NanoOfSecond extends java.lang.Object implements Calendrical, java.lang.Comparable<NanoOfSecond>, TimeAdjuster, CalendricalMatcher, java.io.Serializable
NanoOfSecond is an immutable time field that can only store a nano-of-second. It is a type-safe way of representing a nano-of-second in an application.
Static factory methods allow you to construct instances. The nano-of-second may be queried using getValue().
NanoOfSecond is immutable and thread-safe.
Modifier and Type | Field and Description |
---|---|
static NanoOfSecond |
ZERO
A singleton instance for zero nanoseconds.
|
Modifier and Type | Method and Description |
---|---|
LocalTime |
adjustTime(LocalTime time)
Adjusts a time to have the the nano-of-second represented by this object,
returning a new time.
|
int |
compareTo(NanoOfSecond otherNanoOfSecond)
Compares this nano-of-second instance to another.
|
boolean |
equals(java.lang.Object otherNanoOfSecond)
Is this instance equal to that specified, evaluating the nano-of-second.
|
<T> T |
get(CalendricalRule<T> rule)
Gets the value of the specified calendrical rule.
|
java.math.BigDecimal |
getFractionalValue()
Gets the value as a fraction of a second between 0 and 1.
|
int |
getValue()
Gets the nano-of-second value.
|
int |
hashCode()
A hash code for the nano-of-second object.
|
boolean |
matchesCalendrical(Calendrical calendrical)
Checks if the nano-of-second extracted from the calendrical matches this.
|
static NanoOfSecond |
nanoOfSecond(Calendrical calendrical)
Obtains an instance of
NanoOfSecond from a calendrical. |
static NanoOfSecond |
nanoOfSecond(int nanoOfSecond)
Obtains an instance of
NanoOfSecond . |
static DateTimeFieldRule<java.lang.Integer> |
rule()
Gets the rule that defines how the nano-of-second field operates.
|
java.lang.String |
toString()
A string describing the nano-of-second object.
|
public static final NanoOfSecond ZERO
public static DateTimeFieldRule<java.lang.Integer> rule()
The rule provides access to the minimum and maximum values, and a generic way to access values within a calendrical.
public static NanoOfSecond nanoOfSecond(int nanoOfSecond)
NanoOfSecond
.nanoOfSecond
- the nano-of-second to represent, from 0 to 999,999,999public static NanoOfSecond nanoOfSecond(Calendrical calendrical)
NanoOfSecond
from a calendrical.
This can be used extract the nano-of-second value directly from any implementation
of Calendrical
, including those in other calendar systems.
calendrical
- the calendrical to extract from, not nullUnsupportedRuleException
- if the nano-of-second cannot be obtainedpublic <T> T get(CalendricalRule<T> rule)
This method queries the value of the specified calendrical rule.
If the value cannot be returned for the rule from this instance then
null
will be returned.
get
in interface Calendrical
rule
- the rule to use, not nullpublic int getValue()
public java.math.BigDecimal getFractionalValue()
The fractional value is between 0 (inclusive) and 1 (exclusive). The fraction will have the minimum scale necessary to represent the fraction.
public boolean matchesCalendrical(Calendrical calendrical)
matchesCalendrical
in interface CalendricalMatcher
calendrical
- the calendrical to match, not nullpublic LocalTime adjustTime(LocalTime time)
Only the nano-of-second field is adjusted in the result. The other time fields are unaffected.
This instance is immutable and unaffected by this method call.
adjustTime
in interface TimeAdjuster
time
- the time to be adjusted, not nullpublic int compareTo(NanoOfSecond otherNanoOfSecond)
compareTo
in interface java.lang.Comparable<NanoOfSecond>
otherNanoOfSecond
- the other nano-of-second instance, not nulljava.lang.NullPointerException
- if otherNanoOfSecond is nullpublic boolean equals(java.lang.Object otherNanoOfSecond)
equals
in class java.lang.Object
otherNanoOfSecond
- the other nano-of-second instance, null returns falsepublic int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object