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

歡迎訪問 生活随笔!

生活随笔

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

java

java 根据类名示例化类_Java LocalDateTime类| ofInstant()方法与示例

發布時間:2025/3/11 java 47 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java 根据类名示例化类_Java LocalDateTime类| ofInstant()方法与示例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

java 根據類名示例化類

LocalDateTime類的Instant()方法 (LocalDateTime Class ofInstant() method)

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

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

  • ofInstant() method is used to create an instance of LocalDateTime from the given instant and zone.

    ofInstant()方法用于從給定的瞬間和區域創建LocalDateTime的實例。

  • ofInstant() method may throw an exception at the time of representing the object.

    ofInstant()方法在表示對象時可能會引發異常。

    DateTimeException – This exception may throw when this LocalDateTime value reaches out of the min or max instant.

    DateTimeException –當此LocalDateTime值超出最小或最大瞬間時,可能會引發此異常。

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

    ofInstant()方法是一個靜態方法,可以使用類名進行訪問,如果我們嘗試使用類對象訪問這些方法,則不會出錯。

Syntax:

句法:

public static LocalDateTime ofInstant(Instant ins, ZoneId zo);

Parameter(s):

參數:

  • Instant ins – represents the instant by which we are creating LocalDateTime.

    Instant ins –表示我們創建LocalDateTime的瞬間。

  • ZoneId zo – represents the time zone.

    ZoneId zo –代表時區。

Return value:

返回值:

The return type of this method is LocalDateTime, it returns the LocalDateTime that holds the value creates from the given Instant and zone.

該方法的返回類型為LocalDateTime ,它返回LocalDateTime,該LocalDateTime包含從給定的Instant和zone創建的值。

Example:

例:

// Java program to demonstrate the example // of ofInstant(Instant ins, ZoneId zo) method // of LocalDateTimeimport java.time.*;public class OfInstantOfLocalDateTime {public static void main(String args[]) {// Instantiates a ZoneId and// InstantZoneId zo = ZoneId.of("Africa/Accra");Instant ins = Instant.parse("2006-04-03T05:10:15.00Z");// Here, this method creates an instance of // LocalDateTime by using the given// Instant and ZoneIdLocalDateTime da_ti = LocalDateTime.ofInstant(ins, zo);// Display da_tiSystem.out.print("LocalDateTime.ofInstant(ins,zo): ");System.out.println(da_ti);} }

Output

輸出量

LocalDateTime.ofInstant(ins,zo): 2006-04-03T05:10:15

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

java 根據類名示例化類

總結

以上是生活随笔為你收集整理的java 根据类名示例化类_Java LocalDateTime类| ofInstant()方法与示例的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。