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

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

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

問題描述

限時送ChatGPT賬號..

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

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]

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

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

您應(yīng)該使用 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()),在本例中為轉(zhuǎn)儲一堆關(guān)于 Calendar 對象狀態(tài)的有用信息,但不是真正的人類可讀數(shù)據(jù).

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 方法來顯示日期值, 根據(jù)當(dāng)前的本地設(shè)置格式化,這將提供更多有用的信息.

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,而應(yīng)該使用系統(tǒng)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 ;)

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

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

相關(guān)文檔推薦

Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期時間,就像在 UTC 中一樣)
How to convert Gregorian string to Gregorian Calendar?(如何將公歷字符串轉(zhuǎn)換為公歷?)
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 日之前日期的日歷到日期轉(zhuǎn)換.公歷到儒略歷切換)
java Calendar setFirstDayOfWeek not working(java日歷setFirstDayOfWeek不起作用)
Java: getting current Day of the Week value(Java:獲取當(dāng)前星期幾的值)
主站蜘蛛池模板: 综合国产 | 99久热在线精品视频观看 | 黄视频网址 | 久久国产精品视频 | 精品国产欧美在线 | 夜操| 自拍偷拍亚洲欧美 | 可以看黄的视频 | 国产日韩精品一区 | 久久国产亚洲 | 久久国产精品一区二区三区 | 超碰精品在线观看 | 日韩喷潮 | av天空| 男女羞羞免费视频 | 美国黄色一级片 | 黄色欧美 | 欧美精品在线播放 | 你懂的免费在线 | 极情综合网 | 成人国产免费视频 | 国产一区二区 | 夫妻午夜影院 | 在线视频日韩精品 | 欧美一级小视频 | 天堂中文av| 一区二区免费看 | av免费在线观看网站 | h在线播放 | 国产在线高清 | 一区二区三 | 国产成人精品视频在线观看 | 国产精品视频一区二区三区, | 狠狠操婷婷 | 欧美精品第一区 | 国产乱码一二三区精品 | 亚洲xxxxx| 欧美激情久久久 | 久久伊 | 日韩有码一区二区三区 | 亚洲经典一区 |