开发者

How to create own calendar reminder in Java? [closed]

开发者 https://www.devze.com 2023-02-16 03:41 出处:网络
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this
Closed. This question needs to be more focused. It is not currently accepting answers.

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 7 years ago.

Improve this question

We have a calendar in our web application. Events can be added to the calendar, and events will have some start date and end date.

Events can also have a reminder. So, while adding an event, if a user decides to he notified of the event by a reminder email, the user can set the reminder value in the event. Similar to what we have in Outlook.

For example, Event Name: Weekly Meeting

Start date: 1st March, 10 AM

Reminder: 1 hour (it can be 15min, 30 min, 1 hr, 2 hr, 1 day, 2 day, etc).

So, in this case an 开发者_Python百科email should be sent to the user before the event, that is, 1 hour before.

An event table in the database has event name, start date, reminder.

How do I implement this in Java?


If you don't want to use an external scheduler, a Java Timer can be used. You need to implement the TimerTask interface and schedule it using the Timer for whatever frequency you require. The TimerTask should simply query the database to get all the upcoming events and send emails.

To get all the upcoming events, use the proper SQL syntax for your database -

WHERE (START_DATE - TODAY) < REMINDER_ADVANCE

To send email, use the Java mail API.


You might want to run a scheduled job that checks the events and reminders and sends emails if necessary.

If you're using an application server like JBoss you could use the Quartz scheduler (JBoss normally contains a version of quartz already). Then set the job to run at the lowest reminder granularity, e.g. every 15 minutes.


Modern way: You may integrate your web application with some of the cloud reminder services - Google calendar, RTM, ToodleDo, etc. Google calendar has a Java API to their calendar service, others have useful APIs as well.

0

精彩评论

暂无评论...
验证码 换一张
取 消