Return to Snippet

Revision: 11356
at February 3, 2009 00:24 by hansamann

Initial Code
import net.fortuna.ical4j.util.Calendars
import net.fortuna.ical4j.model.component.VEvent
import java.text.SimpleDateFormat

    def url = ''.toURL()
    def cal = Calendars.load(url)

    def dayFormatter = new SimpleDateFormat("EEEEEEEE, MMMMMMMM dd'th' yyyy", Locale.US)
    def timeFormatter = new SimpleDateFormat('HH:mm', Locale.US)

    def dates = []
    def now = new Date() 
    log.debug("Total components in iCal file: ${cal.components.size()}" )

    cal.components.findAll { > now.time }.sort { }.each
      if (!it instanceof VEvent)
        log.warn("Found event of class ${it.getClass()}, skipping!")

      def startDate = dayFormatter.format(
      def startTime = timeFormatter.format(

      def eventMap = [
              startDate : startDate,
              startTime : startTime,
              location : (it.location.value) ? it.location.value : 'No Location',
              summary : it.summary.value,
              description : it.description.value

      dates << eventMap

Initial URL

Initial Description
Thanx to Guillaume Laforge, who provided this code snippet of Groovy code in a GSP. The snippet below is more or less the same, less the HTML. It will show all future evens and create a eventMap for each event.

Initial Title
Parse Events from iCal URL or File (e.g. Google Calendar)

Initial Tags

Initial Language