Main types

The whenever library provides four main date-time types, each with its own purpose and behavior:

The available methods differ between these types based on whether they represent exact time or local time:

type

represents exact time?

represents local time?

Instant

ZonedDateTime

OffsetDateTime

PlainDateTime

Exact time methods

The exact time classes (Instant, ZonedDateTime, and OffsetDateTime) share several methods for working with exact points in time:

Instant

ZonedDateTime

OffsetDateTime

now()

🔗

🔗

🔗

timestamp() [1]

🔗

🔗

🔗

from_timestamp() [2]

🔗

🔗

🔗

to_fixed_offset()

🔗

🔗

🔗

to_tz()

🔗

🔗

🔗

to_system_tz()

🔗

🔗

🔗

x > other_exact [3]

🔗

🔗

🔗

x - other_exact

🔗

🔗

🔗

x == other_exact

🔗

🔗

🔗

exact_eq()

🔗

🔗

🔗

x + TimeDelta

🔗

🔗

🔗

Local time methods

The local time classes (PlainDateTime, ZonedDateTime, and OffsetDateTime) share several methods for working with local date and time values:

PlainDateTime

ZonedDateTime

OffsetDateTime

year, month, etc.

🔗

🔗

🔗

hour, minute, etc.

🔗

🔗

🔗

date()

🔗

🔗

🔗

time()

🔗

🔗

🔗

replace() [4]

🔗

🔗

🔗

add(), subtract()

🔗, 🔗

🔗, 🔗

🔗, 🔗

since(), until()

🔗, 🔗

🔗, 🔗

🔗, 🔗

round()

🔗

🔗

🔗

Note

Although Instant’s debug representation is in UTC, it does not have local time methods. See the FAQ for more details.

Other methods

Several other methods are unique to one or more classes: