问题
In a previous version of grails I was able to use the groovy enhanced version of java.util.Date found here here.
After upgrading to grails 4, all those methods throw no signature of method on java.util.Date. Somehow the groovy additions aren't being picked up.
def fdate=new Date();
out << fdate.format("MM/dd/yyyy")
//No signature of method: java.util.Date.format()
回答1:
Add a dependency to groovy-dateutil
to your build.gradle
:
runtime 'org.codehaus.groovy:groovy-dateutil'
The relevant extension method is defined at https://github.com/apache/groovy/blob/master/subprojects/groovy-dateutil/src/main/java/org/apache/groovy/dateutil/extensions/DateUtilExtensions.java#L526-L528, which is in the groovy-dateutil
library.
来源:https://stackoverflow.com/questions/57548284/grails-4-groovys-date-enhancement-methods-missing