Menu

How can I check if I have an event today ?

Anonymous
2015-10-23
2015-10-24
  • Anonymous

    Anonymous - 2015-10-23

    Hello

    I am learning biweekly recently, will use it in my application.
    It has spent my some time to find a solution about getting events by a specific date(or time). for example:

    I define a calendar with recurrenced event below, how can I check if I have this event tomorrow or not by programming ?

     ICalendar iCalendar = new ICalendar();
     VEvent vEvent = new VEvent();
     vEvent.setDateStart(new Date());
     Recurrence recurrence = new   Recurrence.Builder(Recurrence.Frequency.DAILY).interval(1).byHour(3).byMinute(0).bySecond(0).build();
    vEvent.setRecurrenceRule(recurrence);
    iCalendar.addEvent(vEvent);
    

    Thank you very much!

    Bruce

     
  • Michael Angstadt

    Hi Bruce,

    You can use the RecurrenceRule.getDateIterator() method to get all of the dates in a recurrence rule.

    :::java
    ICalendar ical = ...
    VEvent event = ical.getEvents().get(0);
    Date start = event.getDateStart().getValue();
    RecurrenceRule rrule = event.getRecurrenceRule();
    Iterator<Date> it = rrule.getDateIterator(start);
    while (it.hasNext()){
      Date date = it.next();
      ...
    }
    
     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.