Java Duration类| isZero()方法与示例
持续时间类isZero()方法 (Duration Class isZero() method)
isZero() method is available in java.time package.
isZero()方法在java.time包中可用。
isZero() method is used to check whether this Duration object holds the value of length is 0 or not.
isZero()方法用于检查此Duration对象是否保持length的值为0。
isZero() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.
isZero()方法是一个非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。
isZero() method does not throw an exception at the time of checking 0 lengths.
在检查0个长度时, isZero()方法不会引发异常。
Syntax:
句法:
public boolean isZero();
Parameter(s):
参数:
None
没有
Return value:
返回值:
The return type of this method is boolean, it returns true when this Duration value length is 0 otherwise it returns false.
此方法的返回类型为boolean ,当Duration值的长度为0时返回true,否则返回false。
Example:
例:
// Java program to demonstrate the example
// of boolean isZero() method of Duration
import java.time.*;
public class IsZeroOfDuration {public static void main(String args[]) {// Instantiates three Duration objects
Duration du1 = Duration.ofHours(-10);
Duration du2 = Duration.parse("P1DT2H20M");
Duration du3 = Duration.ofMinutes(0);
// Display du1, du2 and du3
System.out.println("du1: " + du1);
System.out.println("du2: " + du2);
System.out.println("du3: " + du3);
System.out.println();
// checks whether the value
// of this Duration (du1) is zero
// or not i.e here it returns false because
// the value of du1 is not 0
boolean status = du1.isZero();
// Display status
System.out.println("du1.isZero(): " + status);
// checks whether the value
// of this Duration (du2) is zero
// or not i.e here it returns false because
// the value of du2 is not 0
status = du2.isZero();
// Display status
System.out.println("du2.isZero(): " + status);
// checks whether the value
// of this Duration (du3) is zero
// or not i.e here it returns true because
// the value of du3 is 0
status = du3.isZero();
// Display status
System.out.println("du3.isZero(): " + status);
}
}
Output
输出量
du1: PT-10H
du2: PT26H20M
du3: PT0Sdu1.isZero(): false
du2.isZero(): false
du3.isZero(): true
翻译自: https://www.includehelp.com/java/duration-iszero-method-with-example.aspx
Java Duration类| isZero()方法与示例相关推荐
- 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日历类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 ...
- java日历类add方法_Java日历setFirstDayOfWeek()方法与示例
java日历类add方法 日历类setFirstDayOfWeek()方法 (Calendar Class setFirstDayOfWeek() method) setFirstDayOfWeek( ...
- java日历类add方法_Java日历setMinimalDaysInFirstWeek()方法与示例
java日历类add方法 日历类setMinimalDaysInFirstWeek()方法 (Calendar Class setMinimalDaysInFirstWeek() method) se ...
- java散列法的运用实例,Java HashMap compute() 使用方法及示例
Java HashMap compute() 使用方法及示例 Java HashMap compute()方法计算一个新值,并将其与哈希映射中的指定键相关联. compute()方法的语法为: has ...
- Java——String类的方法
Java--String类的方法 String str1 = "abc" 与String str2 = new String("abc")有什么区别? 字符串常 ...
- java播放声音类和一个简单示例
java播放声音类和一个简单示例 播放声音的类 复制代码 代码如下: import java.io.File; import java.io.IOException; import javax.so ...
最新文章
- ndk-build: CreateProcess error=193
- tableau的2020.3在mac上可以使用,2020.4不行:亲测有效
- 使用设计模式构建通用数据库访问类
- java mongo 查询数组_MongoDB查询(数组、内嵌文档)
- Python二级笔记(12)
- 我想做产品,实现一个非常优秀的电脑桌面记事本加闹钟
- 利用Ajax实现DataGrid无刷新分页(AjaxGrid)【转】
- java ee 设计模式_Java EE 设计模式解析与应用_源雷技术空间
- java web项目个人博客_javaWeb项目个人博客系统
- iOS 应用内付费(IAP)开发步骤
- 在iOS中高效的加载图片
- 计算机网络--七层结构(三)传输层详解
- python截屏保存本地_Python截图并保存的具体实例
- 同态滤波处理夜间雾霾图像
- matlab 折射率椭球,折射率椭球详解.ppt
- 《东周列国志》第二十六回 歌扊扅百里认妻 获陈宝穆公证梦
- Windows下安装Oracle11g数据库
- 计算机毕业设计Java夕阳红养老院系统(源码+系统+mysql数据库+Lw文档)
- 自定义控件之-横线指示器
- 6818联网 8266wifi模块(附源码)
热门文章
- (七)linux函数接口的使用
- python import 路径_python import 上级目录的导入
- 计算机在岗位上的应用,计算机岗位应用论文.doc
- axios代理跨域 cli4_vuecli 3.0之跨域请求代理配置及axios路径配置 莫小龙
- linux lzo 压缩文件,Linux常用压缩和解压命令
- JAVA知识基础(三):修饰符
- 二十多岁不信,三十多岁却深信不疑的道理
- VR究竟多奇幻?eSmart邀你共赴一场VR奇幻之旅!
- linux 查看数据库和表 mysql 命令
- HDU 6188 Duizi and Shunzi