Search code examples
javaandroidrfc2445

java.text.parse Exception using google-rfc-2445 library


I am using the google-rfc-2445 library to determine the next meeting days for meeting that I pull from a user's calendar on their android device. The an example format for the recurrence rule I get back is :

FREQ=WEEKLY;UNTIL=20140826T223000Z;WKST=MO;BYDAY=TU  

I'm using DateIteratorFactory.createDateIterator() to determine the next meeting date. If I turn strict mode off, then the beginning date of the meeting is all that's returned. With strict mode on, nothing is returned and when I read through the log, I see an error message that says :

"java.text.ParseException: FREQ=WEEKLY;UNTIL=20140826T223000Z;WKST=MO;BYDAY=TU

(at offset 0)".

Any ideas? I'll list my code below, for example sake, I just use the system time in my example.

    rrule = "Date start = new Date(System.currentTimeMillis());"
    Date start = new Date(System.currentTimeMillis());
    TimeZone dt = TimeZone.getDefault();
    // Next Notification
    Date f = null;
    try {
        DateIterator di = DateIteratorFactory.createDateIterator(rrule, start, dt, true);
    } catch (ParseException e) {
        e.printStackTrace();
    }

    System.out.println("Next = " + f);

Solution

  • I figured out the problem. I had to append "RRULE:" to the beginning of the recurrence rule String.