Java即时类| isSupported()方法与示例
即时类isSupported()方法 (Instant Class isSupported() method)
Syntax:
句法:
public boolean isSupported (TemporalField t_field);
public boolean isSupported (TemporalUnit t_unit);
isSupported() method is available in java.time package.
isSupported()方法在java.time包中可用。
isSupported (TemporalField t_field) method is used to identify whether this given field is supported or not on this Instant.
isSupported(TemporalField t_field)方法用于标识此Instant是否支持此给定字段。
isSupported (TemporalUnit t_unit) method is used to identify whether this given unit is supported or not on this Instant.
isSupported(TemporalUnit t_unit)方法用于标识此Instant是否支持此给定的单位。
These methods don't throw an exception at the time of checking status.
这些方法在检查状态时不会引发异常。
These are non-static methods and it is accessible with class objects and if we try to access these methods with the class name then we will get an error.
这些是非静态方法,可通过类对象访问,如果尝试使用类名访问这些方法,则会收到错误消息。
Parameter(s):
参数:
In the first case, "isSupported (TemporalField t_field)",
在第一种情况下,“ isSupported(TemporalField t_field)”,
- TemporalField t_field – represents the field to be checked for support.
- TemporalField t_field –表示要检查支持的字段。
In the second case, "isSupported (TemporalUnit t_unit)",
在第二种情况下,“ isSupported(TemporalUnit t_unit)”,
- TemporalUnit t_unit – represents the unit to be checked for support.
- TemporalUnit t_unit –表示要检查支持的单位。
Return value:
返回值:
In both the cases, the return type of the method is boolean,
在这两种情况下,方法的返回类型均为boolean 。
In the first case, it returns true when the given field is supported at this Instant otherwise it returns false.
在第一种情况下,当此Instant支持给定字段时,它返回true,否则返回false。
In the second case, it returns true when the given unit is supported at this Instant.
在第二种情况下,当此Instant支持给定单位时,它返回true。
Example:
例:
// Java program to demonstrate the example
// of isSupported() method of Instant
import java.time.*;
import java.time.temporal.*;
public class IsSupportedOfInstant {public static void main(String args[]) {// Instantiates two Instant
Instant ins1 = Instant.parse("2006-04-03T05:10:15.00Z");
Instant ins2 = Instant.now();
// Display ins1,ins2
System.out.println("Instant ins1 and ins2: ");
System.out.println("ins1: " + ins1);
System.out.println("ins2: " + ins2);
System.out.println();
// Here, this method checks whether this
// Instant (ins1) support the given
// field or not i.e. here it returns
// true because ins1 supports
// MICRO_OFSECOND
boolean status = ins1.isSupported(ChronoField.MICRO_OF_SECOND);
// Display status
System.out.println("ins1.isSupported(ChronoField.MICRO_OF_SECOND): " + status);
// Here, this method checks whether this
// Instant (ins2) supports the given
// unit or not i.e. here it returns
// true because ins2 supports
// MINUTES
status = ins2.isSupported(ChronoUnit.MINUTES);
// Display status
System.out.println("ins2.isSupported(ChronoUnit.MINUTES): " + status);
}
}
Output
输出量
Instant ins1 and ins2:
ins1: 2006-04-03T05:10:15Z
ins2: 2020-05-28T00:46:53.435757Zins1.isSupported(ChronoField.MICRO_OF_SECOND): true
ins2.isSupported(ChronoUnit.MINUTES): true
翻译自: https://www.includehelp.com/java/instant-issupported-method-with-example.aspx
Java即时类| isSupported()方法与示例相关推荐
- java annotation class,Java Class类 isAnnotation()方法及示例
Class类isAnnotation()方法isAnnotation()方法在java.lang包中可用. isAnnotation()方法用于检查此Class对象是否表示注释类型. isAnnota ...
- java字符类型的返回值,Java字符类isWhitespace()方法及示例
Character 类isWhitespace()法isWhitespace()方法在java.lang包中可用. isWhitespace()方法用于检查给定的char值是否为空格,但是它包含空格中 ...
- Java即时类| plus()方法与示例
即时类plus()方法 (Instant Class plus() method) Syntax: 句法: public Instant plus(TemporalAmount t_amt); pub ...
- Java即时类| toString()方法与示例
即时类toString()方法 (Instant Class toString() method) toString() method is available in java.time packag ...
- Java LocalDate类| isSupported()方法与示例
LocalDate类isSupported()方法 (LocalDate Class isSupported() method) Syntax: 句法: public boolean isSuppor ...
- Java即时类| hashCode()方法与示例
即时类hashCode()方法 (Instant Class hashCode() method) hashCode() method is available in java.time packag ...
- Java即时类| 带示例的compareTo()方法
即时类compareTo()方法 (Instant Class compareTo() method) compareTo() method is available in java.time pac ...
- java日历类add方法_Java日历computeTime()方法及示例
java日历类add方法 日历类computeTime()方法 (Calendar Class computeTime() method) computeTime() method is availa ...
- java日历类add方法_Java日历computeFields()方法及示例
java日历类add方法 日历类的computeFields()方法 (Calendar Class computeFields() method) computeFields() method is ...
最新文章
- openstack组件之nova
- .NET中防止Access数据库下载
- jQuery的eval
- WordPress时间日期函数常用代码
- Windows Sockets 2.0 新特性
- 分享一下淘宝iData技术嘉年华的几点感触
- (39)Verilog HDL参数:localparam
- 向日葵linux 用电脑远程控制与管理,远程控制软件向日葵和teamviewer的区别和使用...
- 美国爱荷华州批准参议院541号文件,允许使用分布式账本技术和智能合约
- HDOJ 1713 相遇周期 (最大公约数与最小公倍数)
- 2012春季ACM内部测试赛3
- hr面试高频问题回答思路总结
- python-白盒测试方法
- GB2312编码理解
- echarts实现中国地图区域分布图 vue + echarts
- mysql 脱裤_mysql 脱裤(脱库)通用脚本 | 学步园
- 监听手机接收短信——模拟获取短信的验证码
- Weakly Supervised Deep Learning for Thoracic DiseaseClassification and Localization on Chest X-rays
- Spring源码分析之AOP源码分析
- 执行宏时出现“在中断模式不能执行程序代码”
热门文章
- 白帽子讲Web安全——服务端安全
- 抖音短视频APP开发进度条(ProgressBar)的功能与用法
- weiphp看版本_序言 · weiphp5.0二次开发手册 · 看云
- 现在好了,初五了,快熬过去了 (2011年02月07日)
- 郭金东旗下利德东方举行2019年综合应急救援演练
- describe和corr的用法详解
- 正则匹配url 参数
- TIDB数据库特性总结
- 百度知道自动登陆他人帐号-是BUG还是产品设计
- python 3des加密_DES/3DES之ECB模式和CBC模式加解密 及 Python 实现