Interface TemporalUnit

All Known Implementing Classes:
ChronoUnit

public interface TemporalUnit
A unit time is measured in. ChronoUnit holds the units of the ISO calendar.
  • Method Summary

    Modifier and Type
    Method
    Description
    <R extends Temporal>
    R
    addTo(R temporal, long amount)
    temporal moved by amount of this unit.
    long
    between(Temporal temporal1Inclusive, Temporal temporal2Exclusive)
    How many whole units lie between two values of the same kind.
    The length of one unit; an estimate for the units a calendar decides.
    boolean
    Whether this is a unit of a date: a day or longer.
    boolean
    Whether the length is an estimate.
    default boolean
    Whether temporal can add or subtract this unit.
    boolean
    Whether this is a unit of a time of day: shorter than a day.
  • Method Details

    • getDuration

      Duration getDuration()
      The length of one unit; an estimate for the units a calendar decides.
    • isDurationEstimated

      boolean isDurationEstimated()
      Whether the length is an estimate.
    • isDateBased

      boolean isDateBased()
      Whether this is a unit of a date: a day or longer.
    • isTimeBased

      boolean isTimeBased()
      Whether this is a unit of a time of day: shorter than a day.
    • isSupportedBy

      default boolean isSupportedBy(Temporal temporal)

      Whether temporal can add or subtract this unit.

      Answered by the unit's kind for the built-in temporals and otherwise by trying to add one, as the JDK's default does. It never asks temporal.isSupported(this): that is what calls here, so a custom unit relying on this default would recurse.

    • addTo

      <R extends Temporal> R addTo(R temporal, long amount)
      temporal moved by amount of this unit.
    • between

      long between(Temporal temporal1Inclusive, Temporal temporal2Exclusive)
      How many whole units lie between two values of the same kind.