2012-10-05

Groovy Date Format one-liner

new Date().format("yyyy-MM-dd")

This method has been added to java.util.Date




Current date (mm/dd/yyyy) (Groovy forum at JavaRanch)
:

import org.codehaus.groovy.runtime.*;

class Run{
static void main(def args){
def dateTime = new Date()
println DateGroovyMethods.format(dateTime, 'MM/dd/yyyy')
}
}

No comments: