Datetime-related SDKs.
Time zone is an artificial concept, and only matters when a specific locale is concerned.
Contrary to intuition, the phrase local time means timezone-irrelevant, i.e. the class in question has no field storing timezone information.
Before Java 8: java.util.Date & Java.util.Calendar
#
Java 8 and Later: java.time.*
#
interface Temporal & final Class Instant Implements Temporal
#
A Temporal instance represents an instant in an arbitrary time range.
An amount of time can be added to this, subtracted from this, yet still produce a Temporal
The final class Instant implements Temporal by encapsulating a long for seconds since epoch and an int for nanosecond of that second.
Notable methods:
static Instant now()static Instant ofEpochMillis(long millis)long until(Temporal endExclusive, TemporalUnit unit)
Uniting: interface TemporalUnit and enum ChronoUnit Implements TemporalUnit
#
Each ChronoUnit enum instance is just an Duration with a descriptive name.
Time-Zone-Agnostic: java.time.LocalDate / java.time.LocalDateTime / java.time.LocalTime
#
Local means time-zone agnostic.
Conceputally,
LocalDateis a(year-month-day)triplet,LocalTimeis a(hour-minute-second)triplet,LocalDateTimeis a(year-month-day-hour-minute-second)sextet.
Notable methods (on all 3 classes)
long until(Temporal endExclusive, TemporalUnit unit)Calculates the amount of time until another date in terms of the specified unit.
Comments
Read or comment on GitHub (sign-in required to comment)