java.time.chrono.JapaneseDate类的isSupported()方法用于检查是否支持特定的chrono字段。
用法:
public boolean isSupported(TemporalField field)
参数:此方法接受“时间”字段的类型,以检查该时间是否与特定日期兼容。
返回值:如果此日期与传递的字段兼容,则此方法返回布尔值,否则返回true,否则返回false。
下面的示例说明了hashCode()方法:
范例1:
// Java program to demonstrate
// isSupported() method
import java.util.*;
import java.io.*;
import java.time.*;
import java.time.chrono.*;
import java.time.temporal.*;
public class GFG {
public static void main(String[] argv)
{
try {
// creating and initializing
// JapaneseDate Object
JapaneseDate hidate = JapaneseDate.now();
// checking for the
// given ChronoField
// by using isSupported() method
boolean status = hidate.isSupported(
ChronoField.ERA);
// display the result
if (status)
System.out.println(
"this field is supported");
else
System.out.println(
"this field is not supported");
}
catch (DateTimeException e) {
System.out.println("passed parameter can"
+ " not form a date");
System.out.println("Exception thrown:" + e);
}
}
}
输出:
this field is supported
范例2:
// Java program to demonstrate
// isSupported() method
import java.util.*;
import java.io.*;
import java.time.*;
import java.time.chrono.*;
import java.time.temporal.*;
public class GFG {
public static void main(String[] argv)
{
try {
// creating and initializing
// JapaneseDate Object
JapaneseDate hidate = JapaneseDate.now();
// checking for the
// given ChronoField
// by using isSupported() method
boolean status = hidate.isSupported(
ChronoField.MICRO_OF_DAY);
// display the result
if (status)
System.out.println(
"this field is supported");
else
System.out.println(
"this field is not supported");
}
catch (DateTimeException e) {
System.out.println("passed parameter can"
+ " not form a date");
System.out.println("Exception thrown:" + e);
}
}
}
输出:
this field is not supported
相关用法
- Java JapaneseDate from()用法及代码示例
- Java JapaneseDate of(int, int, int)用法及代码示例
- Java JapaneseDate getLong()用法及代码示例
- Java JapaneseDate getEra()用法及代码示例
- Java JapaneseDate getChronology()用法及代码示例
- Java JapaneseDate of(JapaneseEra,int, int, int)用法及代码示例
- Java JapaneseDate equals()用法及代码示例
- Java JapaneseDate atTime()用法及代码示例
- Java JapaneseDate toString()用法及代码示例
- Java JapaneseDate toEpochDay()用法及代码示例
- Java JapaneseDate range()用法及代码示例
- Java JapaneseDate hashCode()用法及代码示例
- Java JapaneseDate lengthOfYear()用法及代码示例
- Java JapaneseDate now(Clock)用法及代码示例
- Java JapaneseDate lengthOfMonth()用法及代码示例
注:本文由纯净天空筛选整理自RohitPrasad3大神的英文原创作品 JapaneseDate isSupported() method in Java with Example。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。