I have this problem. I need to do the following:
- get todays date
- make a new date which will be today’s date at 00:00:00
- make another date which will be today’s date at 23:59:59
For example. Today Date is 12-January-2012 19:00
How can i make a new date, which will be 12-January-2012 00:00 (the start of the current day)
It may seems easy, but i couldnt find any groovyway to get it, any help would be apreciated.
To get the date at midnight use
Date.clearTime(docs):(Javadocs are for Groovy JDK < 2.0,
clearTime()is declaredvoidin Groovy JDK 2.0, preventingd = new Date().clearTime(). Comments indicate the original functionality may be restored, yay!)For the comparison, instead of using
<= 23:59:59, use< (the next day):