Reusable Java library of general tools with minimal external dependencies.
For questions or support, please contact us:
Email: support@aoindustries.com
Phone: 1-800-519-9541
Phone: +1-251-607-9556
Web: https://www.aoindustries.com/contact
public class Instant extends Object implements Comparable<Instant>, Serializable, ObjectInputValidation
This will be deprecated once Java 8 is ubiquitous and only serves as an extremely simplified stop-gap.
| Constructor and Description |
|---|
Instant(long epochSecond,
int nano) |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(Instant other) |
boolean |
equals(Instant other) |
boolean |
equals(Object obj) |
long |
getEpochSecond() |
int |
getNano()
The nanoseconds, to simplify this is always in the positive direction.
|
int |
hashCode() |
Instant |
plusNanos(long nanosToAdd) |
String |
toString() |
void |
validateObject() |
static Instant |
valueOf(String s)
Parses an Instant's string representation.
|
public static final Instant EPOCH
public static Instant valueOf(String s)
IllegalArgumentException - when unable to parsepublic void validateObject()
throws InvalidObjectException
validateObject in interface ObjectInputValidationInvalidObjectExceptionpublic boolean equals(Instant other)
public int compareTo(Instant other)
compareTo in interface Comparable<Instant>public long getEpochSecond()
public int getNano()
The nanoseconds, to simplify this is always in the positive direction. For negative instants, this means the nanos goes up from zero to 1 billion, then the seconds go up one (toward zero). This may be counterintuitive if one things of nanoseconds as a fractional part of seconds, but this definition leads to a very clean implementation.
Counting up by nanoseconds:
public Instant plusNanos(long nanosToAdd)
Copyright © 2000–2016 AO Industries, Inc.. All rights reserved.