本文介紹了一個(gè)月的最后一天計(jì)算的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
限時(shí)送ChatGPT賬號(hào)..
我在計(jì)算預(yù)定發(fā)送通知的下一個(gè)月最后一天的時(shí)間時(shí)遇到問題.
I am having issues with the calculation of when the next Last Day of the Month is for a notification which is scheduled to be sent.
這是我的代碼:
RecurrenceFrequency recurrenceFrequency = notification.getRecurrenceFrequency();
Calendar nextNotifTime = Calendar.getInstance();
我認(rèn)為這是導(dǎo)致問題的原因:
This is the line causing issues I believe:
nextNotifTime.add(recurrenceFrequency.getRecurrencePeriod(),
recurrenceFrequency.getRecurrenceOffset());
如何使用日歷正確設(shè)置通知的下個(gè)月的最后一天?
How can I use the Calendar to properly set the last day of the next month for the notification?
推薦答案
Calendar.getInstance().getActualMaximum(Calendar.DAY_OF_MONTH);
這將返回當(dāng)前月份的實(shí)際最大值.例如現(xiàn)在是閏年的二月,所以它返回 29 作為 int
.
This returns actual maximum for current month. For example it is February of leap year now, so it returns 29 as int
.
這篇關(guān)于一個(gè)月的最后一天計(jì)算的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!