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 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 –
To send email, use the Java mail API.