Home Reference Source Repository
import {TemporalUnit} from 'js-joda/src/temporal/TemporalUnit.js'
public interface | source


Direct Subclass:

ChronoUnit, src/temporal/IsoFields.js~Unit

A unit of date-time, such as Days or Hours.

Measurement of time is built on units, such as years, months, days, hours, minutes and seconds. Implementations of this interface represent those units.

An instance of this interface represents the unit itself, rather than an amount of the unit. See Period for a class that represents an amount in terms of the common units.

The most commonly used units are defined in ChronoUnit. Further units are supplied in IsoFields. Units can also be written by application code by implementing this interface.

The unit works using double dispatch. Client code calls methods on a date-time like {@code LocalDateTime} which check if the unit is a {@code ChronoUnit}. If it is, then the date-time must handle it. Otherwise, the method call is re-dispatched to the matching method in this interface.