SyntaxHighlighter

Thursday, July 7, 2011

Groovy Date clearTime() method

Groovy has a nice Date class defined.
One I learned to use recently is clearTime() method.
Date today = new Date().clearTime()
This should result to today's date with no time component attached to it.

But, my code kept on failing.
So I dug around a bit, and found this: http://jira.codehaus.org/browse/GROOVY-4788

I was on groovy 1.7.3, because my project's on grails 1.3.7. As you can see on the jira page, at this version of groovy, clearTime() does not have a return value.

Watch out for it if you are stuck!

After thought: groovy 1.8 seem to have very nice improvements over previous versions of groovy. I hope grails 1.4 will get released soon!

No comments:

Post a Comment