So why does this work:
requestInstance.needByDate = new Date() + 4
requestInstance.needByDate.clearTime()
But this doesn't ?
requestInstance.needByDate= (new Date() + 4).clearTime()
EDIT: as indicated b开发者_JAVA百科elow by Tim this is a bug in Groovy version: 1.7.9-SNAPSHOT (the one I am using of course)
I can't get it to not work...
needByDate = new Date() + 4
needByDate.clearTime()
println needByDate
needByDate = (new Date() + 4).clearTime()
println needByDate
Run with Groovy 1.8 prints:
Fri Jul 22 00:00:00 UTC 2011
Fri Jul 22 00:00:00 UTC 2011
What version of Groovy are you running? Maybe a previous version did not have clearTime
returning a Date
?
Edit
Yeah, found it. There was a bug reported that clearTime()
should return a Date
and it was fixed in Groovy 1.8.0 and 1.7.11
精彩评论