getseconds補0_Java Duration類| getSeconds()方法與示例

getseconds補0

持續時間類getSeconds()方法 (Duration Class getSeconds() method)

  • getSeconds() method is available in java.time package.

    getSeconds()方法在java.time包中可用。

  • getSeconds() method is used to return the number of seconds exists in this Duration.

    getSeconds()方法用于返回此Duration中存在的秒數。

  • getSeconds() 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.

    getSeconds()方法是一種非靜態方法,只能通過類對象訪問,如果嘗試使用類名稱訪問該方法,則會收到錯誤消息。

  • getSeconds() method does not throw an exception at the time of getting seconds.

    getSeconds()方法在獲取秒數時不會引發異常。

Syntax:

句法:

    public long getSeconds();

Parameter(s):

參數:

  • None

    沒有

Return value:

返回值:

The return type of this method is long, it returns the number of seconds in this Duration.

此方法的返回類型為long ,它返回此Duration中的秒數。

Example:

例:

// Java program to demonstrate the example 
// of long getSeconds() method of Duration
import java.time.*;
import java.time.temporal.*;
public class GetSecondsOfDuration {
public static void main(String args[]) {
// Instantiates two Duration objects
Duration du1 = Duration.ofHours(1);
Duration du2 = Duration.ofMinutes(5);
// Display du1 and du2
System.out.println("du1: " + du1);
System.out.println("du2: " + du2);
// returns the value in seconds
// i.e. here we are requesting the value 
// of du1 in SECONDS 
long get_sec_val = du1.getSeconds();
// Display get_sec_val
System.out.println("du1.getSeconds(): " + get_sec_val);
// returns the value in seconds
// i.e. here we are requesting the value 
// of du2 in SECONDS 
get_sec_val = du2.getSeconds();
// Display get_sec_val
System.out.println("du2.getSeconds(): " + get_sec_val);
}
}

Output

輸出量

du1: PT1H
du2: PT5M
du1.getSeconds(): 3600
du2.getSeconds(): 300

翻譯自: https://www.includehelp.com/java/duration-getseconds-method-with-example.aspx

getseconds補0

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/379211.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/379211.shtml
英文地址,請注明出處:http://en.pswp.cn/news/379211.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

遞歸-漢諾塔(代碼、分析、匯編)

代碼&#xff1a; #include <stdio.h>void hanoi(int n, char a, char b, char c) {if( n > 0 ){if( n 1 ){printf("%c -> %c\n", a, c);}else{hanoi(n-1, a, c, b);printf("%c -> %c\n", a, c);hanoi(n-1, b, a, c);}} }int main() {han…

if語句(四)

1&#xff0c;簡單if示例 phones [iphone,xiaomi,huawei,smartisan] for phone in phones:if phone huawei:print(phone.upper())#將字符串的所有字母大寫else:print(phone.title())#將字符串中的每個單詞的首字符大寫效果圖如下&#xff1a; 2&#xff0c;if條件測試 ph…

welcome to my blog

轉載于:https://www.cnblogs.com/jiangjun/archive/2012/10/22/2734600.html

kotlin字符串判空_Kotlin程序檢查空字符串,空字符串或NULL字符串

kotlin字符串判空Given a string, we have to check whether it is an empty, blank or NULL string. 給定一個字符串&#xff0c;我們必須檢查它是否為空&#xff0c;空白或NULL字符串。 Example: 例&#xff1a; Input:str ""Output:True用于在Kotlin中檢查Empt…

.net中對象序列化技術淺談 (轉)

原文&#xff1a;http://blog.csdn.net/zhoufoxcn/archive/2009/03/11/3978874.aspx .net中對象序列化技術淺談 (轉&#xff09;序列化是將對象狀態轉換為可保持或傳輸的格式的過程。與序列化相對的是反序列化&#xff0c;它將流轉換為對象。這兩個過程結合起來&#xff0c;可…

遞歸-輸出字符串所有的組合情況(代碼、分析、匯編)

目錄&#xff1a;代碼&#xff1a;分析&#xff1a;匯編&#xff1a;代碼&#xff1a; #include <stdio.h>/*程序描述&#xff1a;輸出字符串所有的組合情況使用permutation函數進行將指定的下標值&#xff0c;與最大下標值這個范圍的每個下標值進行交換每調用一次permu…

課本例子代碼第四章

【例4.1】設計一個控制臺應用程序&#xff0c;采用二分查找方法在給定的有序數組a中查找用戶輸入的值&#xff0c;并提示相應的查找結果。 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;namespace C…

一個簡單的python日志服務器

一個簡單的python日志服務器&#xff0c;主要目的是搜集各python logging記錄的日志&#xff0c;將其簡單匯總。源碼如下&#xff1a; # -*- coding: utf-8 -*-Created on 2012-06-14 19:50 summary: a simple logging server. use gevent and logging modules author: JerryK…

c#中queue_C#中的Queue.Enqueue()方法示例

c#中queueC&#xff03;Queue.Enqueue()方法 (C# Queue.Enqueue() method) Queue.Enqueue() method is used to add an object/element at the end of the Queue. Queue.Enqueue()方法用于在Queue的末尾添加一個對象/元素。 Syntax: 句法&#xff1a; void Queue.Enqueue(Obj…

C#調用Web Service時的身份驗證

轉自&#xff1a;http://www.anqn.com/dev/vc/2010-01-23/a09122769.shtml 在項目開發&#xff0c;我們經常會使用WebService&#xff0c;但在使用WebService時我們經常會考慮以下問題&#xff1a;怎么防止別人訪問我的WebService?從哪里引用我的WebService?對于第一個問題&a…

遞歸-計算字符串長度(代碼、分析、匯編)

目錄&#xff1a;代碼&#xff1a;分析&#xff1a;匯編&#xff1a;代碼&#xff1a; main.c #include <stdio.h>//該程序用遞歸計算字符串長度int strlen(const char* s) {if( s NULL ){return -1;}else if( *s \0 ){return 0;}else{return strlen(s1) 1;} }int m…

Java LinkedList void clear()方法與示例

LinkedList void clear()方法 (LinkedList void clear() method) This method is available in package java.util.Collection and here, Collection is an interface. 該方法在java.util.Collection包中可用&#xff0c;在這里&#xff0c; Collection是一個接口。 This metho…

Python-楊輝三角

在控制臺輸出如圖所示一個8層的楊輝三角。 楊輝三角介紹&#xff1a; 每個數等于它上方兩數之和 每行數字左右對稱&#xff0c;由1開始逐漸變大 第n行的數字有n項&#xff0c;將n取8 def yanghui(n):l[1,1]for x in range(1,n):for a in range(x):l[a]l[a]l[a1]l.insert(0,1)…

如何向妻子解釋OOD(轉)

前言 此文譯自CodeProject上<How I explained OOD to my wife>一文&#xff0c;該文章在Top Articles上排名第3&#xff0c;讀了之后覺得非常好&#xff0c;就翻譯出來&#xff0c;供不想讀英文的同學參考學習。 作者(Shubho)的妻子(Farhana)打算重新做一名軟件工程師(她…

不安全代碼和指針資料匯編

不安全代碼和指針&#xff08;C# 編程指南&#xff09;為了保持類型安全&#xff0c;默認情況下&#xff0c;C# 不支持指針運算。不過&#xff0c;通過使用 unsafe 關鍵字&#xff0c;可以定義可使用指針的不安全上下文。有關指針的更多信息&#xff0c;請參見主題指針類型。 注…

ffmpeg-從flv文件中提取AAC音頻數據保存為文件

AAC ADTS格式協議&#xff1a; 從flv文件中提取AAC音頻數據保存為文件。 如果需要詳細了解AAC ADTS格式&#xff0c;可以查詢文檔。 原文件&#xff1a; 提取aac文件&#xff1a; main.c #include <stdio.h> #include <libavutil/log.h>> #include <lib…

Python-統計《水調歌頭·明月幾時有》字符出現次數。

統計《水調歌頭明月幾時有》字符出現次數。 明月幾時有&#xff0c;把酒問青天。 不知天上宮闕&#xff0c;今夕是何年&#xff1f; 我欲乘風歸去&#xff0c;又恐瓊樓玉宇&#xff0c;高處不勝寒。 起舞弄清影&#xff0c;何似在人間&#xff01; 轉朱閣&#xff0c;低綺戶&am…

Linux網絡編程入門 (轉載)

(一)Linux網絡編程--網絡知識介紹 Linux網絡編程--網絡知識介紹客戶端和服務端 網絡程序和普通的程序有一個最大的區別是網絡程序是由兩個部分組成的--客戶端和服務器端. 客戶端 在網絡程序中&#xff0c;如果一個程序主動和外面的程序通信&#xff0c;那么我們…

在Python中將字符串拆分為字符數組

Given a string and we have to split into array of characters in Python. 給定一個字符串&#xff0c;我們必須在Python中拆分為字符數組。 將字符串拆分為字符 (Splitting string to characters) 1) Split string using for loop 1)使用for循環分割字符串 Use for loop t…

SQL表值函數和標量值函數的區別 [轉]

SQL表值函數和標量值函數的區別 寫sql存儲過程經常需要調用一些函數來使處理過程更加合理&#xff0c;也可以使函數復用性更強&#xff0c;不過在寫sql函數的時候可能會發現&#xff0c;有些函數是在表值函數下寫的有些是在標量值下寫的&#xff0c;區別是表值函數只能返回一個…