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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/541474.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

《C#多线程编程实战(原书第2版)》——3.2 在线程池中调用委托

本节书摘来自华章出版社《C#多线程编程实战(原书第2版)》一书中的第3章,第3.2节,作者(美)易格恩阿格佛温(Eugene Agafonov),黄博文 黄辉兰 译,更多章节内容可…

mysql语句数据库_数据库的Mysql语句

数据库的mysql语句: 1.连接数据库 mysql -u root -p2.显示数据库 show databases(db);3.选择数据库 use 数据库名;4.显示数据库中的表 show tables;基本数据操作:增删改查1.增 :insert into 表名(字段1,字段2…)values (值1,值2…);2.删 :delete from 表名 where 条件;3.改 :up…

java clock计时_Java Clock类| systemUTC()方法与示例

java clock计时Clock Class systemUTC()方法 (Clock Class systemUTC() method) systemUTC() method is available in java.time package. systemUTC()方法在java.time包中可用。 systemUTC() method is used to get a Clock that implements the suitable system clock in the…

《Android 应用测试指南》——第2章,第2.4节包浏览器

本节书摘来自异步社区《Android 应用测试指南》一书中的第2章,第2.4节包浏览器,作者 【阿根廷】Diego Torres Milano(迭戈 D.),更多章节内容可以访问云栖社区“异步社区”公众号查看 2.4 包浏览器创建完前面提到的两个…

操作系统系统调用_操作系统中的系统调用

操作系统系统调用系统调用简介 (Introduction to System calls) The interface between the operating system and the user program is defined by the set of extended instruction that the operating system provides. These extended instructions are known as system ca…

java分数表示_表示Java分数的最佳方法?

小编典典碰巧的是不久前我写了一个BigFraction类,用于解决Euler项目问题。它保留了BigInteger分子和分母,因此它将永远不会溢出。但是,对于许多你永远不会溢出的操作来说,这会有点慢。无论如何,请根据需要使用它。我一…

《OpenStack云计算实战手册(第2版)》——1.7 添加用户

本节书摘来自异步社区《OpenStack云计算实战手册(第2版)》一书中的第1章,第1.7节,作者: 【英】Kevin Jackson , 【美】Cody Bunch 更多章节内容可以访问云栖社区“异步社区”公众号查看。 1.7 添加用户 在OpenStack身份认证服务中…

开源软件和自由软件_自由和开源软件的经济学

开源软件和自由软件零边际成本 (Zero Marginal Cost) At the core of the financial aspects of Free and Open Source is the zero negligible expense of merchandise in an environment that is digital. Right now, the rise of Free and Open Source speaks to an affirma…

java外部类_Java里什么叫内部类什么叫外部类

展开全部对普通类(没有内部类的类)来说,62616964757a686964616fe78988e69d8331333337396234内部类和外部类都与他无关;对有内部类的类来说,它们就是其内部类的外部类,外部类是个相对的说法,其实就是有内部类的类。所以…

《精通Matlab数字图像处理与识别》一6.2 傅立叶变换基础知识

本节书摘来自异步社区《精通Matlab数字图像处理与识别》一书中的第6章,第6.2节,作者 张铮 , 倪红霞 , 苑春苗 , 杨立红,更多章节内容可以访问云栖社区“异步社区”公众号查看 6.2 傅立叶变换基础知识 精通Matlab数字图像处理与识别要理解傅立…

多线程循环输出abcc++_C ++循环| 查找输出程序| 套装5

多线程循环输出abccProgram 1: 程序1&#xff1a; #include <iostream>using namespace std;int main(){int num 15673;int R1 0, R2 0;do {R1 num % 10;R2 R2 * 10 R1;num num / 10;} while (num > 0);cout << R2 << " ";return 0;}Ou…

java oql_深入理解java虚拟机(八):java内存分析工具-MAT和OQL

以下内容翻译自MAT帮助文档。一、Class HistogramClass Histogram shows the classes found in the snapshot, the number of objects for each class, the heap memory consumption of these objects, and the minimum retained size of the objects二、Dominator treeDomina…

《Python数据分析与挖掘实战》一1.2 从餐饮服务到数据挖掘

本节书摘来自华章出版社《Python数据分析与挖掘实战》一书中的第1章&#xff0c;第1.2节&#xff0c;作者 张良均 王路 谭立云 苏剑林&#xff0c;更多章节内容可以访问云栖社区“华章计算机”公众号查看 1.2 从餐饮服务到数据挖掘 企业经营最大的目的就是盈利&#xff0c;而餐…

obj[]与obj._Ruby中带有示例的Array.include?(obj)方法

obj[]与obj.Ruby Array.include&#xff1f;(obj)方法 (Ruby Array.include?(obj) Method) In the previous articles, we have seen how we can check whether two Array instances are identical or not with the help of <> operator, operator, and .eql? method?…

java javah_Java开发网 - 一个javah的问题

Posted by:jerry_xuPosted on:2006-03-13 15:39我在环境变量中已经设置了path为D:\Program Files\Java\jdk1.5.0_06&#xff0c;ClassPath设置为.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;class的路径为&#xff1a;D:\JNItest\bin\jni\Hello.class &#xff0c;但是…

《Python面向对象编程指南》——2.7 __del__()方法

本节书摘来自异步社区《Python面向对象编程指南》一书中的第2章&#xff0c;第2.7节&#xff0c;作者&#xff3b;美&#xff3d;Steven F. Lott&#xff0c; 张心韬 兰亮 译&#xff0c;更多章节内容可以访问云栖社区“异步社区”公众号查看。 2.7 __del__()方法 __del__()方…

NullReferenceException C#中的异常

什么是NullReferenceException&#xff1f; (What is NullReferenceException?) NullReferenceException is an exception and it throws when the code is trying to access a reference that is not referencing to any object. If a reference variable/object is not refe…

java map key 大写转小写_Spring JdbcTemplate 查询出的Map,是如何产生大小写忽略的Key的?(转)...

Java 是区分大小写的&#xff0c;普通的Map例如HashMap如果其中的key"ABC" value"XXX"那么map.get("Abc") 或 map.get("abc")是获取不到值得。但Spring中产生了一个忽略大小写的map使我产生了好奇例如 jdbcTemplate.queryForList(sql)…

《iOS 6核心开发手册(第4版)》——2.11节秘诀:构建星星滑块

本节书摘来自异步社区《iOS 6核心开发手册&#xff08;第4版&#xff09;》一书中的第2章&#xff0c;第2.11节秘诀&#xff1a;构建星星滑块&#xff0c;作者 【美】Erica Sadun&#xff0c;更多章节内容可以访问云栖社区“异步社区”公众号查看 2.11 秘诀&#xff1a;构建星星…

css框架和js框架_优雅设计的顶级CSS框架

css框架和js框架Brief discussion: 简要讨论&#xff1a; Well, who doesnt want their website or web page to look attractive, stylish and be responsive? 那么&#xff0c;谁不希望自己的网站或网页看起来有吸引力&#xff0c;时尚并且ReactSwift&#xff1f; We put …