6 May 2011

How to parse a date in Groovy ?

Solution based on Groovy 1.8.0

def dateFormat = 'dd-MM-yyyy' // set format (you can do this when you parse as well)
Date dateExample = Date.parse(dateFormat,dateStart) // parse date
println(dateExample) // print on console ;)

More about how to format date you can find here: http://download.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html

More about Date class in groovy you can find here :  http://groovy.codehaus.org/JN0545-Dates

No comments:

Post a Comment