Revision: 11356
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
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 = 'http://www.google.com/calendar/ical/jds6o8imt8qgtepchsmr72jhf4%40group.calendar.google.com/public/basic.ics'.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 {it.startDate.date.time > now.time }.sort { it.startDate.date }.each { if (!it instanceof VEvent) { log.warn("Found event of class ${it.getClass()}, skipping!") return; } def startDate = dayFormatter.format(it.startDate.date) def startTime = timeFormatter.format(it.startDate.date) 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
http://grailspodcast.com
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
groovy
Initial Language
Groovy