問題描述
我正在嘗試獲取本月的今天.
I am trying to get todays day of the month.
我想做的是在數(shù)字上加上 7 天,然后得到當(dāng)月的那一天.
And what i want to do is add seven days to the number and the get that current day of the month.
我還希望它能夠到下個月......讓我們說今天是 29 日.當(dāng)它增加 7 天時,我怎樣才能讓它在下個月如 29 + 7 等于下個月的 5 號.
Also i want it to be able to go to the next month..Lets say today is the 29th. When it adds 7 days how can i get it to go the the next month such as 29 + 7 would equal the 5th of the next month.
我該怎么做呢?
我已經(jīng)設(shè)法得到當(dāng)前日期.
Ive already managed to get the current date.
Calendar cal = Calendar.getInstance();
int day = cal.get(Calendar.DAY_OF_MONTH);
int dayOfMonth = day;
String today = getToday();
我使用它是因為我想每 7 天在我的主要活動中啟動一個異步任務(wù).
I am using this because i would like to launch an asynctask in my main activity every 7 days.
推薦答案
add(Calendar.DAY_OF_MONTH, 7);
來自 日歷 JavaDoc
這篇關(guān)于如何在不超過一個月的可用天數(shù)的情況下將 7 天添加到當(dāng)前日期?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!