Closed marcpa00 closed 11 years ago
That's great, thanks! Particular thanks for updating the other chapters too. Shame that dayOfMonth
isn't supported. date
is horribly misnamed.
Agreed. Worse, is the fact that :
import static java.util.Calendar.*
d = new Date()
assert d != d.updated(YEAR:2000)
fails!
YEAR have to be forced to its value:
import static java.util.Calendar.*
d = new Date()
assert d != d.updated( (YEAR) : 2000)
which is ugly and would probably raise more unnecessary questions in the context of your book.
As you said, the current mapping of String values to Calendar constants (cf. http://groovy.codehaus.org/groovy-jdk/java/util/Calendar.html#set(java.util.Map)) is ill-choosed : dayOfMonth
should have been used instead of date
. I guess the backward compatible way to fix this would be to map every static int
of JDK's Calendar into a camel-case String key name in groovy-jdk ? Do you think this warrants a suggestion on groovy-user mailing list ?
It's probably better to post such a suggestion on groovy-dev
dayOfMonth
is not a valid key for the Map passed toDate.updated()
: usedate
, could also useCalendar.DAY_OF_MONTH
.