Last Updated : 18 Dec, 2018
In ZonedDateTime class, there are two types of isSupported() method depending upon the parameters passed to it.
isSupported(TemporalField field)isSupported()method of a
ZonedDateTimeclass used to check if the specified field is supported by ZonedDateTime class or not means using this method we can check if this ZonedDateTime can be queried for the specified field. The supported fields of ChronoField are:
All other ChronoField instances will return false.
Syntax:public boolean isSupported(TemporalField field)Parameters:
This method accepts one single parameter
fieldwhich is the field to check.
Return value:This method returns
booleanvalue true if the field is supported on this date-time, false if not. Below programs illustrate the isSupported() method:
Program 1: Java
// Java program to demonstrate
// ZonedDateTime.isSupported() method
import java.time.*;
import java.time.temporal.ChronoField;
public class GFG {
public static void main(String[] args)
{
// create a ZonedDateTime object
ZonedDateTime zdt
= ZonedDateTime
.parse(
"2018-12-06T19:21:12.123+05:30[Asia/Calcutta]");
// check ALIGNED_WEEK_OF_YEAR
// is supported in ZonedDateTime
boolean value
= zdt.isSupported(
ChronoField.ALIGNED_WEEK_OF_YEAR);
// print result
System.out.println("ALIGNED_WEEK_OF_YEAR "
+ "Field is supported: "
+ value);
}
}
Output:
ALIGNED_WEEK_OF_YEAR Field is supported: trueisSupported(TemporalUnit unit)isSupported()
method of a
ZonedDateTimeclass used to Check if the specified unit is supported by ZonedDateTime class or not means using this method we can check if this ZonedDateTime can be queried for the specified unit. The supported fields of ChronoUnit are:
All other ChronoUnit instances will return false.
Syntax:public boolean isSupported(TemporalUnit unit)Parameters:
This method accepts one single parameter
unitwhich is the unit to check.
Return value:This method returns
booleanvalue true if the field is supported on this date-time, false if not. Below programs illustrate the isSupported() method:
Program 1: Java
// Java program to demonstrate
// ZonedDateTime.isSupported() method
import java.time.*;
import java.time.temporal.ChronoUnit;
public class GFG {
public static void main(String[] args)
{
// create a ZonedDateTime object
ZonedDateTime lt
= ZonedDateTime
.parse(
"2018-12-06T19:21:12.123+05:30[Asia/Calcutta]");
// check MILLENNIA ChronoUnit supported
// in ZonedDateTime
boolean value
= lt.isSupported(ChronoUnit.MILLENNIA);
// print result
System.out.println("ChronoUnit MILLENNIA "
+ "is supported: "
+ value);
}
}
Output:
ChronoUnit MILLENNIA is supported: trueReference:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4