开发者

Groovy: Date clearTime() question

开发者 https://www.devze.com 2023-03-21 09:07 出处:网络
So why does this work: requestInstance.needByDate = new Date() + 4 requestInstance.needByDate.clearTime()

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

0

精彩评论

暂无评论...
验证码 换一张
取 消