OffsetDateTime isSupported(TemporalField field) example
Description
OffsetDateTime isSupported(TemporalField field)
checks if the specified field is supported.
This checks if this date-time can be queried for the specified field.
The supported fields are:
NANO_OF_SECOND /*from w w w . j a v a 2s. c o m*/
NANO_OF_DAY
MICRO_OF_SECOND
MICRO_OF_DAY
MILLI_OF_SECOND
MILLI_OF_DAY
SECOND_OF_MINUTE
SECOND_OF_DAY
MINUTE_OF_HOUR
MINUTE_OF_DAY
HOUR_OF_AMPM
CLOCK_HOUR_OF_AMPM
HOUR_OF_DAY
CLOCK_HOUR_OF_DAY
AMPM_OF_DAY
DAY_OF_WEEK
ALIGNED_DAY_OF_WEEK_IN_MONTH
ALIGNED_DAY_OF_WEEK_IN_YEAR
DAY_OF_MONTH DAY_OF_YEAR
EPOCH_DAY
ALIGNED_WEEK_OF_MONTH
ALIGNED_WEEK_OF_YEAR
MONTH_OF_YEAR
PROLEPTIC_MONTH
YEAR_OF_ERA
YEAR
ERA
INSTANT_SECONDS
OFFSET_SECONDS
Syntax
isSupported
has the following syntax.
public boolean isSupported(TemporalField field)
Example
The following example shows how to use isSupported
.
import java.time.OffsetDateTime;
import java.time.temporal.ChronoField;
//www . j av a2 s . co m
public class Main {
public static void main(String[] args) {
OffsetDateTime o = OffsetDateTime.now();
boolean l = o.isSupported(ChronoField.DAY_OF_WEEK);
System.out.println(l);
}
}
The code above generates the following result.