久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在特定日期之后的下周一獲得第一個?

Get first next Monday after certain date?(在特定日期之后的下周一獲得第一個?)
本文介紹了在特定日期之后的下周一獲得第一個?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我知道這里也有同樣的問題,但我試過了提供的答案,它返回了一個我不明白的輸出.我對答案感到困惑,我認為輸出不正確.

I know there is the same question here, but I have tried the answer provided and it returned an output that I don't understand. I am confused by the answer and I don't think the output is correct.

我需要幫助,謝謝:)

GregorianCalendar date1 = new GregorianCalendar( 2014, 05, 12 ); //05 is june as month start from 0 -11

while( date1.get( Calendar.DAY_OF_WEEK ) != Calendar.MONDAY )
    date1.add( Calendar.DATE, 1 );  

System.out.println(date1);

這是輸出:

java.util.GregorianCalendar[time=1405267200000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Asia/Singapore",offset=28800000,dstSavings=0,useDaylight=false,transitions=9,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2014,MONTH=6,WEEK_OF_YEAR=29,WEEK_OF_MONTH=3,DAY_OF_MONTH=14,DAY_OF_YEAR=195,DAY_OF_WEEK=2,DAY_OF_WEEK_IN_MONTH=2,AM_PM=0,HOUR=0,HOUR_OF_DAY=0,MINUTE=0,SECOND=0,MILLISECOND=0,ZONE_OFFSET=28800000,DST_OFFSET=0]

我應該提取輸出的哪個位置來檢索星期一的日期?

Where on the output should I extract to retrieve Monday's date?

推薦答案

Java 8+

LocalDate ld = LocalDate.of(2014, Month.JUNE, 12);
System.out.println(ld);
ld = ld.with(TemporalAdjusters.next(DayOfWeek.MONDAY));
System.out.println(ld);

哪些打印...

2014-06-12
2014-06-16

因為我的實際日期可能是星期一,所以您也可以使用...

Because it's possible that the date my actually be a Monday, you could also use...

ld = ld.with(TemporalAdjusters.nextOrSame(DayOfWeek.MONDAY));

Java <= 7

您應該使用 ThreeTen Backport,它為您提供 Java 8 Date/的支持時間接口

Java <= 7

You should be using the ThreeTen Backport, which gives you the support of the Java 8 Date/Time API

代替 System.out.println(date1); 使用 System.out.println(date1.getTime());

getTime 返回一個 Date 的實例,它表示 Calendar

getTime returns an instance of Date which represents the current state of the Calendar

這將輸出 Mon Jul 14 00:00:00 EST 2014

System.out.println(date1) 等價于使用 System.out.println(date1.toString()),在本例中為轉儲一堆關于 Calendar 對象狀態的有用信息,但不是真正的人類可讀數據.

System.out.println(date1) is the equivlent of using System.out.println(date1.toString()), which, in this case, is dumping a bunch of useful info about the state of the Calendar object, but not really human readable data.

System.out.println(date1.getTime()) 將使用 Date 的 to toString 方法來顯示日期值, 根據當前的本地設置格式化,這將提供更多有用的信息.

System.out.println(date1.getTime()) will use the Date's to toString method to display a date value, formatted based on the current local settings, which will provide more useful information.

更新

不要使用GregorianCalendar,而應該使用系統Calendar,例如...

Instead of using GregorianCalendar, you should use the system Calendar, for example...

Calendar date1 = Calendar.getInstance();
date1.set(2014, 06, 12);

此外,月份是 0 索引的,這意味著 Janurary 實際上是 0 而不是 1,因此在您的示例中,您指定了月份為 7 月,而不是 6 月.

Also, months are 0 indexed, meaning that Janurary is actually 0 not 1, so in your example, you've specified the month as July, not June.

所以,相反,使用...

So, instead, using...

Calendar date1 = Calendar.getInstance();
date1.set(2014, 05, 12);

while (date1.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) {
    date1.add(Calendar.DATE, 1);
}

System.out.println(date1.getTime());

哪個輸出了...

Mon Jun 16 16:22:26 EST 2014

從今天開始是下周一...或多或少 ;)

Which is next Monday from today...more or less ;)

這篇關于在特定日期之后的下周一獲得第一個?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期時間,就像在 UTC 中一樣)
How to convert Gregorian string to Gregorian Calendar?(如何將公歷字符串轉換為公歷?)
Java: What/where are the maximum and minimum values of a GregorianCalendar?(Java:GregorianCalendar 的最大值和最小值是什么/在哪里?)
Calendar to Date conversion for dates before 15 Oct 1582. Gregorian to Julian calendar switch(1582 年 10 月 15 日之前日期的日歷到日期轉換.公歷到儒略歷切換)
java Calendar setFirstDayOfWeek not working(java日歷setFirstDayOfWeek不起作用)
Java: getting current Day of the Week value(Java:獲取當前星期幾的值)
主站蜘蛛池模板: 成人av一区二区三区在线观看 | 精品一区二区三区av | 日韩在线视频免费 | 嫩草视频在线观看 | 亚洲欧美日本在线 | 国产91在线播放 | 免费在线观看黄 | 国产精品久久久久久久 | 中文字幕欧美日韩 | 69av在线| 国产高清91 | 国产精品久久久一区二区三区 | 国产福利一区二区三区 | 黄色片在线播放 | 国产精品久久久999 成人在线国产 | 欧美日韩国产在线 | 日韩久久视频 | 亚洲成人免费网站 | 毛片毛片毛片毛片毛片 | 日韩精品免费看 | 欧美不卡在线观看 | 欧美国产视频 | 国产二区视频在线观看 | 久久av免费观看 | 久草资源站 | 国产伦理一区 | 国产ts在线 | 91亚洲视频| 黄色免费一级片 | 日韩精品国产一区 | 黄色免费片 | 久久久久蜜桃 | 欧美一区二区三区在线视频 | 五月天婷婷激情 | 国产中文字幕在线播放 | www.亚洲一区 | 国产伦理一区 | 国产成人在线视频 | 91精品国产成人观看 | 老司机午夜视频 | 影音先锋中文字幕在线 |