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.pswp.cn/news/541474.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/541474.shtml
英文地址,請注明出處:http://en.pswp.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 …