Java LocalDateTime類| 帶示例的getDayOfWeek()方法

LocalDateTime類getDayOfWeek()方法 (LocalDateTime Class getDayOfWeek() method)

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

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

  • getDayOfWeek() method is used to get the field value day-of-week that is an enum DayOfWeek from this date-time object.

    getDayOfWeek()方法用于獲取星期幾的字段值,該字段值為該日期時間對象的枚舉DayOfWeek。

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

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

  • getDayOfWeek() method does not throw an exception at the time of getting the day of the week.

    getDayOfWeek()方法在獲取星期幾時不會引發異常。

Syntax:

句法:

    public DayOfWeek getDayOfWeek();

Parameter(s):

參數:

  • None

    沒有

Return value:

返回值:

The return type of this method is DayOfWeek, it returns the value day-of-week.

此方法的返回類型為DayOfWeek ,它返回星期幾的值。

Example:

例:

// Java program to demonstrate the example 
// of getDayOfWeek() method of LocalDateTime
import java.time.*;
public class GetDayOfWeekOfLocalDateTime {
public static void main(String args[]) {
// Instantiates two LocalDateTime
LocalDateTime da_ti1 = LocalDateTime.parse("2005-10-05T10:10:10");
LocalDateTime da_ti2 = LocalDateTime.now();
// Display da_ti1, da_ti2
System.out.println("LocalDateTime da_ti1 and da_ti2: ");
System.out.println("da_ti1: " + da_ti1);
System.out.println("da_ti2: " + da_ti2);
System.out.println();
// Here, this method returns the field value
// day-of-week that is an enum DayOfWeek
// from this date-time object (da_ti1)
DayOfWeek dow = da_ti1.getDayOfWeek();
// Display dow
System.out.println("da_ti1.getDayOfWeek(): " + dow);
// Here, this method returns the field value
// day-of-week that is an enum DayOfWeek
// from this date-time object (da_ti2)
dow = da_ti2.getDayOfWeek();
// Display dow
System.out.println("da_ti2.getDayOfWeek(): " + dow);
}
}

Output

輸出量

LocalDateTime da_ti1 and da_ti2: 
da_ti1: 2005-10-05T10:10:10
da_ti2: 2020-06-05T02:39:20.357805da_ti1.getDayOfWeek(): WEDNESDAY
da_ti2.getDayOfWeek(): FRIDAY

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

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

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

相關文章

軟件測試方法大匯總

軟件測試方法大匯總 軟件測試方法種類繁多,記憶起來混亂, 如果把軟件測試方法進行分類, 就會清晰很多。 我參考一些書籍和網上的資料, 把常用的軟件測試方法列出來, 讓大家對軟件測試行業有個總體的看法。 從測試設計方法分類 測試…

web安全----xss工具使用3

XSSer 0x01 安裝 環境:kali、python3(必須是python3,kali默認為python2) 安裝步驟: git clone https://github.com/epsylon/xsser.git cd xsser sudo python3 setup.py install 使用命令: xsser -h查看…

Java——多線程(死鎖)

死鎖是指:兩個或兩個以上的進程在執行過程中,由于競爭資源或者由于彼此通信而造成的一種阻塞的現象,若無外力作用,它們都將無法推進下去。此時稱系統處于死鎖狀態或系統產生了死鎖,這些永遠在互相等待的進程稱為死鎖進…

c# 前導0_C#| 用前導零填充整數

c# 前導0To pad an integer number with leading zero, we can use String.Format() method which is library method of String class in C#. 要用前導零填充整數,我們可以使用String.Format()方法,該方法是C#中String類的庫方法。 using S…

走到盡頭的技術-MVC

MVC技術是一種WebApplication設計技術,相比于傳統Web應用程序,MVC可以使程序結構更加清晰,他采用 Model,View,Controller 來管理和架構我們的Web資源,將不同的請求(request)導向不同…

Search Engine -垂直搜索小匯總

FilesTube: 共享文件搜索引擎,文件來自:Rapidshare, MegaUpload, Megashares, YouSendIt, SaveFile, FileFront和Badongo等很多文件儲存網站,支持的文件格式包括:AVI, MP3, MPEG, MPG, RAR, WMA, WMV, EXE, ZIP等,主要為媒體格式,不支持中文 Picsearch:專業圖片搜索引擎,中文界…

Java——多線程(線程安全問題)

同步為安全,不同步為不安全;也就是有synchronized這個標識符,就為線程安全,反之,為線程不安全。 ①Vector是線程安全的 ②StringBuffer是線程安全的 ③Hashtable是線程安全的 Collections.synchronized(xxx)&#…

web安全---XSS利用平臺BLUE-LOTUS安裝與使用

0x01 安裝 環境:windows、phpstudy 下載地址:https://gitee.com/gid1314/BlueLotus_XSSReceiver-master 下載后將文件解壓,重命名為blue,放在www目錄下 訪問:http://IP/blue 點擊安裝 這里只需要修改后臺登陸密碼和…

C#Convert.ToInt32(bool)方法-將bool值轉換為int

C#Convert.ToInt32(bool)方法 (C# Convert.ToInt32(bool) Method) Convert.ToInt32(bool) Method is used to convert a specific Boolean (bool) value to its equivalent integer (int 32 signed number). Convert.ToInt32(bool)方法用于將特定的布爾值(布爾值)轉…

配置Microsoft Visual SourceSafe 2005的Internet訪問

配置Microsoft Visual SourceSafe 2005的Internet訪問 VSS2005發布以后,早就聽說可以支持Internet訪問,這是一個很有意思的特性。前兩天有空,就安裝配置了一下,成功訪問。現在安裝過程發布出來,大家共享。 步驟0&…

使用delphi 開發多層應用(十)安全訪問服務器

前面講了如何建立和訪問服務器,但是前面建的服務器都沒有安全控制,這里有很大的安全問題,第一是任何人做一個客戶端都可以都可以訪問 服務器。第二是數據在網絡傳輸過程中都是明碼的,沒有加密,使用網絡偵聽器就可以檢測到傳輸的內容。這是一個…

數組push()方法以及JavaScript中的示例

JavaScript push()方法 (JavaScript push() method) push() method is used adds/inserts an element at the end of an array, it returns nothing but changes the length of the array. push()方法用于在數組末尾添加/插入元素,它只返回改變數組的長度&#xff0…

C——整除的尾數

Problem Description 一個整數&#xff0c;只知道前幾位&#xff0c;不知道末二位&#xff0c;被另一個整數除盡了&#xff0c;那么該數的末二位該是什么呢&#xff1f; Input 輸入數據有若干組&#xff0c;每組數據包含二個整數a&#xff0c;b&#xff08;0< a<10000…

web安全---瀏覽器解析提交數據的過程

解碼規則 html解析器對html文檔進行解析&#xff0c;完成解析并創建DOM樹JavaScript或者CSS解析器對內聯腳本進行解析&#xff0c;完成js、css解碼url解碼會根據url所在的順序不同而在JS解碼或者解碼后 解碼順序 html解析第一步執行&#xff0c;而JS解析和URL解析則要根據情…

commons-lang的FastDateFormat性能測試

commons-lang的FastDateFormat是一個thread-safe的&#xff0c;對SimpleDateFormat的一個重新實現。 SimpleDateFormat為什么不是thread-safe的呢&#xff1f;看一下具體實現就知道了&#xff0c;其父類中定義了成員變量Calendar&#xff0c;每次格式化日期時都會先重置這個Cal…

C——Flowers

Problem Description As you know, Gardon trid hard for his love-letter, and now he’s spending too much time on choosing flowers for Angel. When Gardon entered the flower shop, he was frightened and dazed by thousands kinds of flowers. “How can I choose!”…

include函數_include()函數以及JavaScript中的示例

include函數includes() is a predefined function in JavaScript, which is used to check whether a given element exists in the array or not? include()是JavaScript中的預定義函數&#xff0c;用于檢查數組中是否存在給定元素&#xff1f; Example: 例&#xff1a; &l…

利用POI創建OpenOffice中的Excel文件

之所以稱為OpenOffice的Excel文件,我發現了一個特點就是: 一些網站嚴格限定了文件必須為MS的Excel格式的話,用POI的HSSF創建的Excel就會不識別.不知道是什么原因,可能是版本的問題,據說HSSF(令人討厭的電子表格格式)生成的是MS97的格式.但是97-2003的提示中明顯的說明了MS的lib…

批處理文章集錦

http://www.5dmail.net/html/2005-10-17/20051017181702.htmhttp://www.cnblogs.com/glaivelee/archive/2009/10/07/1578737.html轉載于:https://www.cnblogs.com/Jessy/archive/2012/02/29/2372955.html

web安全-----CSRF漏洞

簡述 CSRF&#xff1a;Cross-site request -forgery&#xff0c;跨站請求偽造&#xff0c;是一種web攻擊方式&#xff0c;是由于網站的cookie在瀏覽器中不會過期&#xff0c;只要不關閉瀏覽器或者退出登錄&#xff0c;那以后只要訪問這個網站&#xff0c;都會默認你已經登錄。…