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

歡迎訪問 生活随笔!

生活随笔

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

java

Java LocalDate类| ofYearDay()方法与示例

發布時間:2023/12/1 java 48 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Java LocalDate类| ofYearDay()方法与示例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

LocalDate類的YearDay()方法 (LocalDate Class ofYearDay() method)

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

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

  • ofYearDay() method is used to create an instance of LocalDate object that holds the value from the year and day-of-year.

    ofYearDay()方法用于創建LocalDate對象的實例,該實例保存年份和年份中的值。

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

    ofYearDay()方法是一個靜態方法,可以使用類名進行訪問,如果嘗試使用類對象訪問該方法,則不會收到錯誤。

  • ofYearDay() method may throw an exception at the time of representing the day of the year.

    ofYearDay()方法在表示一年中的某天時可能會引發異常。

    DateTimeException: This exception may throw when the calculated result value exceeds the limit.

    DateTimeException :當計算結果值超出限制時,可能引發此異常。

Syntax:

句法:

public LocalDate ofYearDay(int yyyy, int ddOfyyyy);

Parameter(s):

參數:

  • int yyyy – represents the year and starts from MIN_YEAR to MAX_YEAR.

    int yyyy –表示年份,從MIN_YEAR到MAX_YEAR。

  • int ddOfyyyy – represents the days in a year and the number of days in a year from 1 to 365 (for non-leap) 366 (for leap year).

    int ddOfyyyy –表示一年中的天數和一年中的天數,范圍是1到365(對于非le年)是366(對于leap年)。

Return value:

返回值:

The return type of this method is LocalDate, it returns the LocalDate that holds the value represented from a year and day-of-year.

此方法的返回類型為LocalDate ,它返回LocalDate,該LocalDate包含從年份和年份中表示的值。

Example:

例:

// Java program to demonstrate the example // of ofYearDay(int yyyy, int ddOfyyyy) // method of LocalDateimport java.time.*;public class OfYearDayOfLocalDate {public static void main(String args[]) {int year = 2008;int day_of_year = 50;// Here, this method creates an instance// of LocalDate by using the given year// and day_of_year i.e. 2008-02-19// [year = 2008, day_of_year = 50 // (Jan = 31 days + Feb = 19 days )// {2008, Feb, 19} so 2008-02-19]LocalDate of_year_day = LocalDate.ofYearDay(year, day_of_year);// Display of_year_daySystem.out.println("LocalDate.ofYearDay(year,day_of_year): " + of_year_day);} }

Output

輸出量

LocalDate.ofYearDay(year,day_of_year): 2008-02-19

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

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的Java LocalDate类| ofYearDay()方法与示例的全部內容,希望文章能夠幫你解決所遇到的問題。

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