java.time · java.base · since Java 1.8
Instant
public final class Instant
implements Temporal, TemporalAdjuster, Comparable<Instant>, SerializableA point on the UTC timeline (epoch seconds + nanos) — THE type for event timestamps, logs, and persistence. Zone-free by definition.
Key methods
static Instant now() / now(Clock clock) | Current moment (inject Clock for testability). |
static Instant ofEpochMilli(long) / long toEpochMilli() | Legacy epoch-millis bridge. |
Instant plus(Duration) / isBefore(Instant) | Machine-time arithmetic and comparison. |
ZonedDateTime atZone(ZoneId) | Up to human calendar terms for display. |