YearMonth isSupported(TemporalUnit unit) example
Description
YearMonth isSupported(TemporalUnit unit)
checks if the specified unit is supported.
Syntax
isSupported
has the following syntax.
public boolean isSupported(TemporalUnit unit)
Example
The following example shows how to use isSupported
.
import java.time.YearMonth;
import java.time.temporal.ChronoUnit;
//from www .j ava 2s.c om
public class Main {
public static void main(String[] args) {
YearMonth y = YearMonth.now();
boolean m = y.isSupported(ChronoUnit.YEARS);
System.out.println(m);
}
}
The code above generates the following result.