本文介紹了如何獲取每月第一個星期三的日期 java 日歷的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
限時送ChatGPT賬號..
如何使用 java 日歷類獲取每月下一個星期三的日期.例如:
How would I get the date of the next first Wednesday of the month using the java calendar class. For example:
Today(24/03/2012) the next first Wednesday will be 04/04/2012
On(05/04/2012) the next first Wednesday will be 02/05/2012
謝謝.
推薦答案
在 Java 8 及更高版本中,我們可以使用 java.time 類,包括 LocalDate
和 TemporalAdjusters
和 DayOfWeek
枚舉.請參閱教程.
In Java 8 and later, we can use the java.time classes including LocalDate
and TemporalAdjusters
, and the DayOfWeek
enum. See Tutorial.
LocalDate firstSundayOfNextMonth = LocalDate
.now()
.with( TemporalAdjusters.firstDayOfNextMonth() )
.with( TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY) );
這篇關于如何獲取每月第一個星期三的日期 java 日歷的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!