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 LocalDate
import 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_day
System.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

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

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

相關文章

ASP.NET C#讀寫Cookie的方法!

Cookie (HttpCookie的實例)提供了一種在 Web 應用程序中存儲用戶特定信息的方法。例如,當用戶訪問您的站點時,您可以使用 Cookie 存儲用戶首選項或其他信息。當該用戶再次訪問您的網站時,應用程序便可以檢索以前存儲的信息。 創建Cookie方法…

遞歸-裴波那契數列(代碼、分析、匯編)

目錄&#xff1a;代碼&#xff1a;分析&#xff1a;匯編&#xff1a;代碼&#xff1a; main.c #include <stdio.h>//該程序輸出裴波那契數列 int fibonacci(int n) {if( n > 1 ){return fibonacci(n-1) fibonacci(n-2);//注意&#xff1a;這里調用是一直調用左邊函…

javascript 事件委派

javascript 模擬用戶操作 <a href"javascript:;" onClick"javascript:alert(131231);" id"abc">asdfasdf</a> <script> if(document.all) { document.getElementById(abc).fireEvent(onclick); } else { var evt document.cr…

Java Duration類| isNegative()方法與示例

持續時間類isNegative()方法 (Duration Class isNegative() method) isNegative() method is available in java.time package. isNegative()方法在java.time包中可用。 isNegative() method is used to check whether this Duration object holds the value of length < 0 …

經典例題(一)

1&#xff0c;已知復數 x 6 8j 請寫出它的模、實部、虛部及共軛復數的命令&#xff0c;并寫出運行結果。 X 6 8j print("模為:%d"% abs(X)) print("實部為:%s"% X.real) print("虛部為:%s"% X.imag) print("共軛復數為:%s"% X.co…

asterisk撥號規則

一、前言 本文檔以asterisk-1.4.32為基礎寫作而成&#xff0c;可能和其他版本有些區別。其中參考了一些別的書籍和文章。因為寫的比較倉促&#xff0c;而且基本都是晚上寫的&#xff0c;里面的內容邏輯性和語句沒有仔細斟酌&#xff0c;就是想到什么寫什么&#xff0c;難免有…

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. g…

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

代碼&#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)…