本文介紹了Java - 如何計(jì)算每周的第一天和最后一天的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
限時(shí)送ChatGPT賬號(hào)..
我正在嘗試創(chuàng)建一個(gè)如下所示的每周日歷: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
如何計(jì)算每周的日期?例如,本周是:
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);
}
這篇關(guān)于Java - 如何計(jì)算每周的第一天和最后一天的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!