public class MutableInstant extends java.lang.Object implements Instant, java.io.Serializable
Instances of this class are not thread-safe and should not be shared between threads.
Modifier and Type | Field and Description |
---|---|
private long |
epochSecond |
private static int |
MILLIS_PER_SECOND |
private int |
nanoOfSecond |
private static int |
NANOS_PER_MILLI |
private static int |
NANOS_PER_SECOND |
Constructor and Description |
---|
MutableInstant() |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object object) |
void |
formatTo(java.lang.StringBuilder buffer)
Writes a text representation of this object into the specified
StringBuilder , ideally without allocating
temporary objects. |
long |
getEpochMillisecond()
Gets the number of milliseconds from the Java epoch of 1970-01-01T00:00:00Z.
|
long |
getEpochSecond()
Gets the number of seconds from the Java epoch of 1970-01-01T00:00:00Z.
|
int |
getNanoOfMillisecond()
Gets the number of nanoseconds, later along the time-line, from the start of the millisecond.
|
int |
getNanoOfSecond()
Gets the number of nanoseconds, later along the time-line, from the start of the second.
|
int |
hashCode() |
void |
initFrom(Clock clock) |
void |
initFrom(Instant other) |
void |
initFromEpochMilli(long epochMilli,
int nanoOfMillisecond)
Updates the fields of this
MutableInstant from the specified epoch millis. |
void |
initFromEpochSecond(long epochSecond,
int nano)
Updates the fields of this
MutableInstant from the specified instant components. |
static void |
instantToMillisAndNanos(long epochSecond,
int nano,
long[] result)
Updates the elements of the specified
long[] result array from the specified instant components. |
java.lang.String |
toString() |
private void |
validateNanoOfMillisecond(int nanoOfMillisecond) |
private void |
validateNanoOfSecond(int nano) |
private static final int MILLIS_PER_SECOND
private static final int NANOS_PER_MILLI
private static final int NANOS_PER_SECOND
private long epochSecond
private int nanoOfSecond
public long getEpochSecond()
Instant
The epoch second count is a simple incrementing count of seconds where second 0 is 1970-01-01T00:00:00Z.
The nanosecond part of the day is returned by Instant.getNanoOfSecond()
.
getEpochSecond
in interface Instant
public int getNanoOfSecond()
Instant
The nanosecond-of-second value measures the total number of nanoseconds from the second returned by Instant.getEpochSecond()
.
getNanoOfSecond
in interface Instant
999,999,999
public long getEpochMillisecond()
Instant
The epoch millisecond count is a simple incrementing count of milliseconds where millisecond 0 is 1970-01-01T00:00:00Z.
The nanosecond part of the day is returned by Instant.getNanoOfMillisecond()
.
getEpochMillisecond
in interface Instant
public int getNanoOfMillisecond()
Instant
The nanosecond-of-millisecond value measures the total number of nanoseconds from the millisecond returned by Instant.getEpochMillisecond()
.
getNanoOfMillisecond
in interface Instant
999,999
public void initFrom(Instant other)
public void initFromEpochMilli(long epochMilli, int nanoOfMillisecond)
MutableInstant
from the specified epoch millis.epochMilli
- the number of milliseconds from the Java epoch of 1970-01-01T00:00:00ZnanoOfMillisecond
- the number of nanoseconds, later along the time-line, from the start of the millisecondprivate void validateNanoOfMillisecond(int nanoOfMillisecond)
public void initFrom(Clock clock)
public void initFromEpochSecond(long epochSecond, int nano)
MutableInstant
from the specified instant components.epochSecond
- the number of seconds from the Java epoch of 1970-01-01T00:00:00Znano
- the number of nanoseconds, later along the time-line, from the start of the secondprivate void validateNanoOfSecond(int nano)
public static void instantToMillisAndNanos(long epochSecond, int nano, long[] result)
long[]
result array from the specified instant components.epochSecond
- (input) the number of seconds from the Java epoch of 1970-01-01T00:00:00Znano
- (input) the number of nanoseconds, later along the time-line, from the start of the secondresult
- (output) a two-element array to store the result: the first element is the number of milliseconds
from the Java epoch of 1970-01-01T00:00:00Z,
the second element is the number of nanoseconds, later along the time-line, from the start of the millisecondpublic boolean equals(java.lang.Object object)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public void formatTo(java.lang.StringBuilder buffer)
StringBuilderFormattable
StringBuilder
, ideally without allocating
temporary objects.formatTo
in interface StringBuilderFormattable
buffer
- the StringBuilder to write into