Stdlib index
- Captured-borrow migration worklist (3.3.3)
- Owned-bind migration worklist (8.2.7)
- Return-side title audit — the ride-through enumeration
- stdlib ownership audit
- stdlib ownership dispositions (plan 1.3.1 / 4.3.1)
aot
codec
codec / csv
codec / json
collection
- ArrayList
- BPlusTree
- Cache
- Collectors
- HashMap
- HashSet
- Heap
- ImmutableList
- ImmutableMap
- ImmutableSet
- LinkedList
- RedBlackTree
- Sort
collection / ltm
concurrent
error
- Exception
- NoOptionalValueException
- NotProvidedException
- RecoverableException
- ScopedBuildFailedException
- ScopeNotActiveException
- Throwable
- UnrecoverableException
gfx
hash
ifx
io
io / file
io / net
io / net / dns
io / net / uri
lang
lang / stream
math
math / fft
math / linalg
math / npio
math / poly
math / random
math / stats
nucleo
- Columns — the Arrow-laid-out substrate
- Fused tensor expressions — Fuse
- Table — the lazy, typed dataframe
- Tape — define-by-run autograd
- Transform intrinsics — Grad, Vmap, Jit
process
reflect
search / distance
search / fuzzy
search / ngram
session
time
- Clock
- DateTimeFormatter
- Duration
- Instant
- LocalDate
- LocalDateTime
- LocalTime
- Period
- ZonedDateTime
- ZoneId
- ZoneOffset
wire
xpu
xpu / mesh
Instant
cajeta.time.Instant — an immutable moment on the UTC timeline with nanosecond
precision, modeled on java.time.Instant. Stored as int64 epochSecond
(seconds since 1970-01-01T00:00:00Z, may be negative) plus int32 nano
(0..999999999), the canonical normalized form so equal instants compare and
hash equally. A pure stack value type: arithmetic is via
Duration, and calendar breakdown is done by projecting through
LocalDateTime at a ZoneOffset. Implements
Comparable, so instants sort chronologically.
Instant t0 = Instant.ofEpochSecond(1000L);
Duration hour = Duration.ofHours(1L);
Instant t1 = t0.plus(hour);
Duration gap = Instant.between(t0, t1); // 1h
boolean earlier = t0.isBefore(t1); // true
Methods
| Signature | |
|---|---|
Instant(int64 epochSecond, int32 nano) | Raw constructor; caller keeps nano in 0..999999999 — prefer the ofEpoch* factories, which normalize |
static Instant ofEpochSecond(int64 epochSecond) ⚑ | The instant epochSecond seconds after the epoch, zero nanos |
static Instant ofEpochSecondAdjust(int64 epochSecond, int64 nanoAdjustment) | Seconds plus a nanosecond adjustment, normalized |
static Instant ofEpochMilli(int64 epochMilli) ⚑ | The instant epochMilli milliseconds after the epoch |
static Instant epoch() ⚑ | The epoch itself, 1970-01-01T00:00:00Z |
int64 getEpochSecond() | Seconds since the epoch (may be negative) |
int32 getNano() | Nanosecond-of-second, 0..999999999 |
int64 toEpochMilli() | Milliseconds since the epoch |
Instant plusSeconds(int64 seconds) | This instant plus seconds seconds |
Instant plusMillis(int64 millis) | This instant plus millis milliseconds, normalized |
Instant plusNanos(int64 nanos) | This instant plus nanos nanoseconds, normalized |
Instant plus(Duration d) | This instant advanced by a Duration |
Instant minus(Duration d) | This instant moved back by a Duration |
static Duration between(Instant start, Instant end) ⚑ | Elapsed Duration from start to end (negative if end precedes start) |
int32 compareTo(Instant other) | Total order on the UTC timeline |
boolean isBefore(Instant other) | True iff strictly before other |
boolean isAfter(Instant other) | True iff strictly after other |
int64 hash() | Content hash mixing the two fields |
static boolean operator== (Instant a, Instant b) | Value equality — a == b |
⚑ = @EntryPoint
See also
- Tour: TimeDemo
- Source:
runtime/src/cajeta/time/Instant.cajeta - Clock — produces the current
Instant; ZonedDateTime — anInstantseen through an offset