views:

772

answers:

2

I'm looking for a Java API to convert ICS (aka iCal) attachments to nicely formatted HTML or plaintext for display purposes. Ideally, it would be able to handle:

  • Converting dates to a specified timezone.
  • Expanding recurrence patterns into human readable sentences.
  • Multiple VCALENDAR records in a single file.

I'm looking at iCal4j, which has a nice DOM parser, but no way to serialize to anything but iCal.

+2  A: 

I didn't find a better alternative to ical4j. I used it fairly successfully. Unfortunately, as you point out, all it does is to bind to XML, with no other way to output it to something else. You could walk the DOM after creation and output the relevant text - although this seems a bit strange since all you want is text/html, I had the same issue and just ended up parsing out the XML.

The iCal4j API is a bit strange and you might want to relax the parsing and enable outlook/notes compatibility to help you along the way. You could write your own Parser and that implements net.fortuna.ical4j.data.CalendarParser and pull out the necessary information into plain text that way. I think the default net.fortuna.ical4j.data.CalendarParserImpl is about 500 lines of code, you could alternatively hack that.

Jon
Sounds like a job for XSLT!
Adam A
+2  A: 

Sorry mate, if you Googled around and found nothing, then its a sure set of unique requirements you got there, time to innovate.

Take what you have, think up some ideas, and try them out, comes with the job!

BakerTheHacker
Yep, wrote my own.
Chase Seibert