duration java_Java Duration類| withSeconds()方法與示例

duration java

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

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

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

  • withSeconds() method is used to represent this Duration with the given seconds.

    withSeconds()方法用于表示給定秒數的持續時間。

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

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

  • withSeconds() method may throw an exception at the time of representing Duration with the given seconds.

    withSeconds()方法在用給定的秒數表示Duration時可能會引發異常。

    DateTimeException: This exception may throw when the given parameter is not valid.

    DateTimeException :如果給定參數無效,則可能引發此異常。

Syntax:

句法:

    public Duration withSeconds(int sec_val);

Parameter(s):

參數:

  • int sec_val – represents the seconds by which to represent this Duration.

    int sec_val –表示表示該持續時間的秒數。

Return value:

返回值:

The return type of this method is Duration, it returns Duration with the given seconds.

此方法的返回類型為Duration ,它以給定的秒數返回Duration。

Example:

例:

// Java program to demonstrate the example 
// of withSeconds(int sec_val) method of Duration
import java.time.*;
public class WithSecondsfDuration {
public static void main(String args[]) {
// Instantiates two Duration objects
Duration du1 = Duration.ofMinutes(2);
Duration du2 = Duration.parse("P0DT1H0M");
// Display du1 and du2
System.out.println("du1: " + du1);
System.out.println("du2: " + du2);
// represents this Duration
// du1 with the given seconds
Duration with_seconds = du1.withSeconds(15);
// Display with_seconds
System.out.println("du1.withSeconds(15): " + with_seconds);
// represents this Duration
// du2 with the given seconds
with_seconds = du2.withSeconds(30);
// Display with_seconds
System.out.println("du2.withSeconds(30): " + with_seconds);
}
}

Output

輸出量

du1: PT2M
du2: PT1H
du1.withSeconds(15): PT15S
du2.withSeconds(30): PT30S

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

duration java

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

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

相關文章

ffmpeg 命令畫中畫效果

畫中畫效果也是和圖片水印一樣使用movie配合overlay實現 使用ffplay預覽一下: ffplay -i cctvhttp.flv -vf “moviecctvhttp.flv[subm];[in][subm]overlayx20:y30[o ut]” -x 640 -y 480 (可以看到是有兩層視頻的) 用個不同的視頻再測試&…

實驗10 SQL Server 數據備份/恢復

實驗10 SQL Server 數據備份/恢復一、實驗目的 1.了解數據庫備份的過程和屬性設置; 2.掌握應用企業管理器備份和恢復數據庫; 3.掌握應用T-SQL備份和恢復數據庫; 4.掌握數據導入/導出的方法。 二、實驗要求 1.創建指定數據庫的備份. 2.恢復數…

指針和數組

數組的概念與指針的概念聯系非常解密。其實數組的標識相當于它的第一個元素的地址,就像一個指針相當于它所指向的第一個元素的地址,因此其實它們是同一個東西 int numbers [20];int * p;下面的賦值為合法的: p numbers; 這里指針p 和numbers…

程序集(初嘗,也是為插件程序準備)

拓展名是EXE或者DLL的.net可執行程序稱為程序集。 .net程序集與一般的EXE,DLL的區別在于,它包含有metadata。 私有程序集 位于應用程序的目錄下。共享程序集 必須有一個特殊的版本號,唯一的名稱,通常安裝在全局程序集緩存&#xf…

Java BigInteger類| 帶示例的shiftLeft()方法

BigInteger類shiftLeft()方法 (BigInteger Class shiftLeft() method) shiftLeft() method is available in java.math package. shiftLeft()方法在java.math包中可用。 shiftLeft() method is used to shift the given number of bits towards the left side in this BigInteg…

匯編語言-011(無符號乘法指令MUL、有符號乘法指令IMUL、對比MUL乘法指令與SHL移位方式、符號位擴展指令,CBW,CWD,CDQ、DIV 無符號除法指令、IDIV 有符號除法指令)

1:無符號乘法指令MUL .386 .model flat,stdcall.stack 4096 ExitProcess PROTO,dwExitCode:DWORD.data val1 WORD 2000h val2 WORD 0100h .code main PROC;8位乘法mov al,5h ;被乘數mov bl,10hmul bl ;AX 0050h ,CF,OF 0;16位乘法mov ax,val1mul val2 ;DX:AX 002000…

編寫一個程序,實現將存放在AX和DX中的32位數據循環右移二進制數的4位。(DX存放高字節內容,AX存放低字節內容)

編寫一個程序,實現將存放在AX和DX中的32位數據循環右移二進制數的4位。(DX存放高字節內容,AX存放低字節內容) P151 例4.9 匯編思路: AX右移四位后,使用BH接收AL的低四位數據,得到BH的八位數據…

[轉 scrum] 大型項目開發使用敏捷是否合適?不該問的問題

原文地址:http://www.scrumcn.com/agiledev/html/?167.html轉載于:https://www.cnblogs.com/cly84920/archive/2010/03/17/4426844.html

匯編語言-012(擴展加法指令ADC、帶借位減法指令SBB、執行加法后進行ASCII調整指令、AAS 、AAM、AAD 、DAA指令將和數轉成壓縮十進制格式)

1:ADC : 擴展加法指令ADC .386 .model flat,stdcall.stack 4096 ExitProcess PROTO,dwExitCode:DWORD.code main PROCmov dl,0mov al,0FFhadd al,0FFh ;ALFEhadc dl,0 ;DL:AL 01FEhmov edx,0mov eax,0FFFFFFFFhadd eax,0FFFFFFFFh ;EAX FFFFFFFEhadc edx,0 …

c#中textbox屬性_C#.Net中的TextBox.Visible屬性與示例

c#中textbox屬性Here we are demonstrating use of Visible property of TextBox Control. 在這里,我們演示了TextBox Control的Visible屬性的使用。 Visible property contains two values 可見屬性包含兩個值 True: Using this - textbox can be visible on par…

VS2010報表

http://technet.microsoft.com/zh-cn/library/dd220516.aspx轉載于:https://www.cnblogs.com/mingyongcheng/archive/2012/09/11/2679722.html

思維的領域特殊性

思維的領域特殊性 1971年,心理學家Danny Kahneman和Amos Tversky做了這樣一個實驗,他們問統計學教授一些不像統計學的統計學問題,其中一個大概如下:假設你生活的城市有兩家醫院,一家大一家小,某一天&#x…

匯編語言-013(DAS 、DAA與DAS、QWORD類型用SBB借位減法、編寫指令將AX符號擴展到EAX,不能使用CWD、用SHR和條件判斷指令將AL循環右移一位、SHLD、壓縮十進制轉換)

1:DAS : SUB或SBB在AL中生成二進制結果,DAS(減法后的十進制調整)轉壓縮十進制格式 .386 .model flat,stdcall.stack 4096 ExitProcess PROTO,dwExitCode:DWORD.code main PROC;計算85-48mov bl,48hmov al,85hsub al,bl ;AL3Dhd…

python程序執行時間_用于在Python中查找程序執行時間的程序

python程序執行時間The execution time of a program is defined as the time spent by the system to execute the task. As we all know any program takes some execution time but we dont know how much. So, dont worry, in this tutorial we will learn it by using the…

公約數和公倍數

描述 小明被一個問題給難住了&#xff0c;現在需要你幫幫忙。問題是&#xff1a;給出兩個正整數&#xff0c;求出它們的最大公約數和最小公倍數。 輸入 第一行輸入一個整數n&#xff08;0< n<10000)&#xff0c;表示有n組測試數據; 隨后的n行輸入兩個整數i,j&#xff08;…

.net 筆記嘗試(二)

.NET筆試題集&#xff08;二&#xff09; 1.using關鍵字有什么用&#xff1f;什么是IDisposable&#xff1f; using可以聲明namespace的引入&#xff0c;還可以實現非托管資源的釋放&#xff0c;實現了IDisposiable的類在using中創建&#xff0c;using結束后會自動調用該對象的…

網上照片之博客照片與網店照片拍攝心得

本文選自《非常攝影手記&#xff1a;2天玩轉單反相機》一書 讓照片在博客上更熱的心得 1.有時美好的不僅是照片&#xff0c;還有拍攝照片的過程。盡量真實全面地記錄自己的攝影過程&#xff0c;展示最感人的自我。 2.不要急功近利&#xff0c;不想成“名博”的博主不是好博主&a…

string.length_C.中的String.Length屬性示例

string.lengthC&#xff03;String.Length屬性 (C# String.Length property) String.Length property is used to get the total number of characters in the string object (length of the string); it calls with this string and returns the total number of characters. …

匯編語言-014(編寫過程的應用、偽指令LEA、ENTER、LEAVE、LOCAL、遞歸函數、INVOKE、ADDR、PROC偽指令聲明過程)

1&#xff1a;編寫過程&#xff0c;僅用移位和加法&#xff0c;實現任意32位符號數與EAX相乘 include Irvine32.inc.stack 4096 ExitProcess PROTO,dwExitCode:DWORD.code main PROC mov eax,80mov ebx,53call BitwiseMultiplycall WriteDecINVOKE ExitProcess,0 main ENDP;EA…

從鍵盤輸入一個字符,判斷其是不是大寫字母,如果是則請輸出這個大寫字母,如果不是請輸出“這不是一個大寫字母”的英文信息(要求:能連續輸出直到輸出“#”結束)。

從鍵盤輸入一個字符&#xff0c;判斷其是不是大寫字母&#xff0c;如果是則請輸出這個大寫字母&#xff0c;如果不是請輸出“這不是一個大寫字母”的英文信息&#xff08;要求&#xff1a;能連續輸出直到輸出“#”結束&#xff09;。 P155 例4.13 DATA SEGMENT STR DB 0DH,0…