Menu

Is it possible to parse just a recurrence rule?

Anonymous
2015-10-07
2015-10-16
  • Anonymous

    Anonymous - 2015-10-07

    Hello!

    I'd like to be able to parse & generate just an rrule String, rather than a
    whole ical file. Is it possible?

    Thanks!

    John

     
  • Michael Angstadt

    Hi John. Sorry for the late reply. It sure is!

    :::java
    Recurrence recur = new Recurrence.Builder(Frequency.WEEKLY).count(5).build();
    RecurrenceRule rrule = new RecurrenceRule(recur);
    RecurrenceRuleScribe scribe = new RecurrenceRuleScribe();
    String result = scribe.writeText(rrule, new WriteContext(ICalVersion.V2_0, new TimezoneInfo()));
    System.out.println(result);
    
    rrule = scribe.parseText(result, null, new ICalParameters(), new ParseContext());
    recur = rrule.getValue();
    System.out.println(recur.getFrequency());
    System.out.println(recur.getCount());
    

    Produces:

    :::text
    FREQ=WEEKLY;COUNT=5
    WEEKLY
    5
    
     

    Last edit: Michael Angstadt 2015-10-16

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.