This method checks if the provided TemporalField is supported by this instance.
This methods check if the provided TemporalUnit is supported by this instance.
package com.logicbig.example.offsettime;
import java.time.OffsetTime;
import java.time.temporal.ChronoField;
public class IsSupportedExample {
public static void main(String... args) {
OffsetTime d = OffsetTime.now();
for (ChronoField chronoField : ChronoField.values()) {
boolean supported = d.isSupported(chronoField);
System.out.printf("%30s: %s%n", chronoField.name(), supported);
}
}
}
Output
NANO_OF_SECOND: true
NANO_OF_DAY: true
MICRO_OF_SECOND: true
MICRO_OF_DAY: true
MILLI_OF_SECOND: true
MILLI_OF_DAY: true
SECOND_OF_MINUTE: true
SECOND_OF_DAY: true
MINUTE_OF_HOUR: true
MINUTE_OF_DAY: true
HOUR_OF_AMPM: true
CLOCK_HOUR_OF_AMPM: true
HOUR_OF_DAY: true
CLOCK_HOUR_OF_DAY: true
AMPM_OF_DAY: true
DAY_OF_WEEK: false
ALIGNED_DAY_OF_WEEK_IN_MONTH: false
ALIGNED_DAY_OF_WEEK_IN_YEAR: false
DAY_OF_MONTH: false
DAY_OF_YEAR: false
EPOCH_DAY: false
ALIGNED_WEEK_OF_MONTH: false
ALIGNED_WEEK_OF_YEAR: false
MONTH_OF_YEAR: false
PROLEPTIC_MONTH: false
YEAR_OF_ERA: false
YEAR: false
ERA: false
INSTANT_SECONDS: false
OFFSET_SECONDS: true
package com.logicbig.example.offsettime;
import java.time.OffsetTime;
import java.time.temporal.ChronoUnit;
public class IsSupportedExample2 {
public static void main(String... args) {
OffsetTime d = OffsetTime.now();
for (ChronoUnit chronoUnit : ChronoUnit.values()) {
boolean supported = d.isSupported(chronoUnit);
System.out.printf("%10s: %s%n", chronoUnit.name(), supported);
}
}
}
Output
NANOS: true
MICROS: true
MILLIS: true
SECONDS: true
MINUTES: true
HOURS: true
HALF_DAYS: true
DAYS: false
WEEKS: false
MONTHS: false
YEARS: false
DECADES: false
CENTURIES: false
MILLENNIA: false
ERAS: false
FOREVER: false