YearMonth isSupported(TemporalUnit unit)
checks if the specified unit is supported.
isSupported
has the following syntax.
public boolean isSupported(TemporalUnit unit)
The following example shows how to use isSupported
.
import java.time.YearMonth; import java.time.temporal.ChronoUnit; //from w w w. ja va 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.