计算的最后一天 [英] last day of month calculation

查看:101
本文介绍了计算的最后一天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在计算下一个最后一天是否计划发送通知时遇到问题。

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();

这是引起我相信问题的行:

This is the line causing issues I believe:

nextNotifTime.add(recurrenceFrequency.getRecurrencePeriod(), 
                  recurrenceFrequency.getRecurrenceOffset());

如何使用日历正确设置通知下一个月的最后一天? / p>

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);

这会返回当前月份的实际最高值。例如,现在是闰年的2月,所以它返回29。

This returns actual maximum for current month. For example it is February of leap year now, so it returns 29.

这篇关于计算的最后一天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆