久久久久久久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:獲取當前星期幾的值)
主站蜘蛛池模板: 天天干夜夜拍 | 麻豆久久精品 | 久久综合狠狠综合久久综合88 | 久久精品小视频 | 免费成人在线网站 | 日韩欧美国产一区二区 | 韩国欧洲一级毛片 | 欧美伦理一区 | 欧美久久电影 | 国产精品毛片av | 国产一级视频免费播放 | 午夜视频在线观看网址 | 亚洲国产精品久久 | 日韩高清中文字幕 | 高清人人天天夜夜曰狠狠狠狠 | 91精品国产一区二区在线观看 | 色综合久 | 亚洲日日夜夜 | 国产精品揄拍一区二区 | 国产婷婷色综合av蜜臀av | 亚洲欧美一区二区三区1000 | 欧美888 | 婷婷丁香在线视频 | 日本成人免费观看 | 婷婷综合在线 | 国产精品一区在线观看 | 日韩欧美精品 | 欧美精品三区 | 国产蜜臀97一区二区三区 | 日韩精品在线一区 | av黄色在线 | 欧美日韩精品一区二区三区视频 | 人人九九 | 爱操av| 成人免费视频网址 | 久草免费在线 | 久久国产精品久久久久久 | 欧美激情精品久久久久久 | 秋霞国产 | 岛国av一区二区 | 午夜a√ |