grails 4 groovy's date enhancement methods missing

只愿长相守 提交于 2021-01-03 05:25:37

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!