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

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

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

問題描述

限時(shí)送ChatGPT賬號..

我知道這里也有同樣的問題,但我試過了提供的答案,它返回了一個(gè)我不明白的輸出.我對答案感到困惑,我認(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)該提取輸出的哪個(gè)位置來檢索星期一的日期?

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

因?yàn)槲业膶?shí)際日期可能是星期一,所以您也可以使用...

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/的支持時(shí)間接口

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 返回一個(gè) Date 的實(shí)例,它表示 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) 等價(jià)于使用 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 實(shí)際上是 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());

哪個(gè)輸出了...

Mon Jun 16 16:22:26 EST 2014

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

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

這篇關(guān)于在特定日期之后的下周一獲得第一個(gè)?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 字符串本地日期時(shí)間,就像在 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)前星期幾的值)
主站蜘蛛池模板: 中国一级大毛片 | 久草在线青青草 | 国产真实精品久久二三区 | 精品一区二区三 | 国产精品毛片一区二区三区 | www.日本在线播放 | 亚洲视频在线一区 | 欧美一二三四成人免费视频 | 亚洲欧美中文日韩在线v日本 | 亚洲v区 | 午夜视频导航 | 欧美成人免费在线视频 | 在线免费观看色 | 99re在线视频观看 | 国产精品国产成人国产三级 | 亚洲欧美日韩精品久久亚洲区 | 一级久久久久久 | 91精品国产麻豆 | 国产在线精品免费 | 天天碰日日操 | 久久精品欧美一区二区三区麻豆 | 天天综合网天天综合色 | 久久久久久久久久久成人 | 视频一区中文字幕 | 天天草夜夜骑 | 国产亚洲欧美在线 | 色天堂影院 | 国产精品免费观看 | 久久中文字幕电影 | 中文字幕在线视频精品 | 91高清视频在线观看 | 国产精品美女 | 狠狠干狠狠操 | 欧美日本亚洲 | 国产精品久久99 | 久久亚洲国产 | 婷婷亚洲综合 | 国产激情在线播放 | 在线免费毛片 | 欧美一区二区三区国产精品 | 91久久|