本文介紹了Java - 如何計算每周的第一天和最后一天的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
限時送ChatGPT賬號..
我正在嘗試創建一個如下所示的每周日歷:http://dhtmlx.com/docs/products/dhtmlxScheduler/sample_basic.html
I'm trying to create a weekly calendar that looks like this: http://dhtmlx.com/docs/products/dhtmlxScheduler/sample_basic.html
如何計算每周的日期?例如,本周是:
How can I calculate every week date? For example, this week is:
周一至周日
6 月 7 日、6 月 8 日、6 月 9 日、6 月 10 日、6 月 11 日、6 月 12 日、6 月 13 日
Monday - Sunday
7 June, 8 June, 9 June, 10 June, 11 June, 12 June, 13 June
推薦答案
我猜這就是你想要的:
// Get calendar set to current date and time
Calendar c = Calendar.getInstance();
// Set the calendar to monday of the current week
c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
// Print dates of the current week starting on Monday
DateFormat df = new SimpleDateFormat("EEE dd/MM/yyyy");
for (int i = 0; i < 7; i++) {
System.out.println(df.format(c.getTime()));
c.add(Calendar.DATE, 1);
}
這篇關于Java - 如何計算每周的第一天和最后一天的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!