In Java, isSupported(...) returns true if a LocalDateTime can work with a given field or unit, and false if it cannot.
There are two versions: one takes a TemporalField (such as ChronoField.HOUR_OF_DAY) and one takes a TemporalUnit (such as ChronoUnit.DAYS). Asking first lets you avoid an UnsupportedTemporalTypeException.
An instance method of java.time.LocalDateTime (since Java 8): call it on a LocalDateTime object. Add import java.time.LocalDateTime; at the top of your file. It comes from TemporalAccessor, which LocalDateTime implements.
Syntax
Pass a field or a unit.
Java
LocalDateTime dt = LocalDateTime.of(2026, 3, 15, 14, 30);
boolean a = dt.isSupported(ChronoField.HOUR_OF_DAY); // true
boolean b = dt.isSupported(ChronoField.OFFSET_SECONDS); // false
boolean c = dt.isSupported(ChronoUnit.DAYS); // true
Call
What it does
dt.isSupported(field)
Can this field be read or set?
dt.isSupported(unit)
Can this unit be added, subtracted, or used with until()?
dt.get(field)
Reads the field. Throws if it is not supported.
dt.plus(n, unit)
Adds in the unit. Throws if it is not supported.
A LocalDateTime supports all date and time fields, but no zone fields. It supports every unit except FOREVER.
Library declarations
Java
// java.time.LocalDateTime
public boolean isSupported(TemporalField field)
public boolean isSupported(TemporalUnit unit)
Parameters
Parameter
Description
field (TemporalField)
A field such as ChronoField.YEAR.
unit (TemporalUnit)
A unit such as ChronoUnit.HOURS. Use one version or the other.
Return Value
Return Value
Description
boolean
true if the field or unit can be used, false if not.