日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > java >内容正文

java

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

發(fā)布時間:2025/3/11 java 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java clock计时_Java Clock类| offset()方法与示例 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

java clock計時

Clock Class offset()方法 (Clock Class offset() method)

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

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

  • offset() method is used to generate a new Clock from the given base clock with added the given Duration.

    offset()方法用于根據(jù)給定的基本時鐘加上給定的Duration來生成新Clock。

  • offset() method is a static method, it is accessible with the class name and if we try to access the method with the class object then we will not get an error.

    offset()方法是一個靜態(tài)方法,可以使用類名進行訪問,如果嘗試使用類對象訪問該方法,則不會出錯。

  • offset() method does not throw an exception at the time of representing Clock.

    offset()方法在表示Clock時不會引發(fā)異常。

Syntax:

句法:

public static Clock offset(Clock base_cl, Duration off);

Parameter(s):

參數(shù):

  • Clock base_cl – represents the base clock in which to add the given duration.

    Clock base_cl –表示要添加給定持續(xù)時間的基本時鐘。

  • Duration off – represents the offset to add to the given base clock (base_cl).

    持續(xù)時間關(guān)閉 –表示要添加到給定基本時鐘(base_cl)的偏移量。

Return value:

返回值:

The return type of this method is Clock, it returns the Clock object that is available with added the given offset.

此方法的返回類型為Clock ,它返回添加了給定偏移量后可用的Clock對象。

Example:

例:

// Java program to demonstrate the example // of offset(Clock base_cl, Duration off) method of Clockimport java.time.*;public class OffsetOfClock {public static void main(String args[]) {// Instantiates two ZoneId for Accra and AsmaraZoneId zone_1 = ZoneId.of("Africa/Accra");ZoneId zone_2 = ZoneId.of("Africa/Asmara");// Initialize two Clock objects // and one DurationClock cl1 = Clock.system(zone_1);Clock cl2 = Clock.system(zone_2);Duration offset = Duration.ofMinutes(20);// generates a new Clock from the// given clock(cl1) with the given duration addedClock cl_offset = cl1.offset(cl1, offset);// Display cl1 and cl_offset instantSystem.out.println("cl1.instant(): " + cl1.instant());System.out.println("cl_offset.instant(): " + cl_offset.instant());System.out.println();// generates a new Clock from the// given clock(cl2) with the given duration addedcl_offset = cl2.offset(cl2, offset);// Display cl2 and cl_offset instantSystem.out.println("cl2.instant(): " + cl2.instant());System.out.println("cl_offset.instant(): " + cl_offset.instant());} }

Output

輸出量

cl1.instant(): 2020-05-13T19:04:36.242559Z cl_offset.instant(): 2020-05-13T19:24:36.322896Zcl2.instant(): 2020-05-13T19:04:36.324623Z cl_offset.instant(): 2020-05-13T19:24:36.327267Z

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

java clock計時

創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎

總結(jié)

以上是生活随笔為你收集整理的java clock计时_Java Clock类| offset()方法与示例的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。