Date/Time intermediate

Instant with nanosecond precision

Get timestamps with microsecond or nanosecond precision.

✕ 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();
🎯

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
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.

Share 𝕏 🦋 in