Instant with nanosecond precision
Get timestamps with microsecond or nanosecond precision.
Code Comparison
✕ Java 8
// Millisecond precision only
long millis =
System.currentTimeMillis();
// 1708012345678
✓ Java 9+
// Microsecond/nanosecond precision Instant now = Instant.now(); // 2025-02-15T20:12:25.678901234Z long nanos = now.getNano();
Why the modern way wins
Higher precision
Microsecond/nanosecond vs millisecond timestamps.
Type-safe
Instant carries its precision — no ambiguous longs.
UTC-based
Instant is always in UTC — no timezone confusion.
Old Approach
Milliseconds
Modern Approach
Nanoseconds
Since JDK
9
Difficulty
intermediate
JDK Support
Instant with nanosecond precision
Available
Widely available since JDK 9 (Sept 2017)
How it works
Java 9 improved the clock resolution so Instant.now() captures microsecond precision on most platforms (nanosecond on some). The old currentTimeMillis() only gives milliseconds.