Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 1.7.1
-
Fix Version/s: 1.7.2, 1.6.9, 1.8-beta-1
-
Component/s: groovy-jdk
-
Labels:None
-
Number of attachments :
Description
Calendar.clearTime() fails if the time part of the date is in the afternoon.
The gdk seems to be doing:
self.clear(Calendar.HOUR_OF_DAY); self.clear(Calendar.HOUR);
I think that second line is unnecessary and breaking things.
Some test code:
// clearTime works for times in the morning def morning = GregorianCalendar.getInstance() morning.set(Calendar.AM_PM, Calendar.AM) morning.clearTime() assert morning.get(Calendar.HOUR_OF_DAY) == 0 // clearTime fails for times in the afternoon def afternoon = GregorianCalendar.getInstance() afternoon.set(Calendar.AM_PM, Calendar.PM) afternoon.clearTime() assert afternoon.get(Calendar.HOUR_OF_DAY) == 0 // fails in Groovy 1.7.1
The javadoc says to use set(Calendar.HOUR_OF_DAY, 0) for that case. Seems to work in my testing. Changed.