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 TypeMethodDescription<R extends Temporal>
RaddTo(R temporal, long amount) temporalmoved byamountof this unit.longHow many whole units lie between two values of the same kind.The length of one unit; an estimate for the units a calendar decides.booleanWhether this is a unit of a date: a day or longer.booleanWhether the length is an estimate.default booleanisSupportedBy(Temporal temporal) Whethertemporalcan add or subtract this unit.booleanWhether 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
Whether
temporalcan 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
temporalmoved byamountof this unit. -
between
-