Sunday, December 6, 2009

Converting String to Date in Groovy

Recently I was looking for a simple way to convert a String object to a Date format in groovy..
below is the example.

In groovy, its just a one liner to make this happen

String timeStampStr = "2009-12-01T12:36:22Z"
def strDate = new Date().parse("yyyy-MM-dd'T'HH:mm:ss'Z'",timeStampStr)
println strDate.