0

When attempting to use the Groovy date extension, clearTime(), the error returned is Cannot find matching method java.util.Date#clearTime(). Please check if the declared type is correct and if the method exists.

When I use:

def date = new Date()
date.clearTime()

I get the previous error.

This happens if I use compileStatic or at runtime if I do not.

Rik
  • 3
  • 3
  • Does this answer your question? [grails 4 groovy's date enhancement methods missing](https://stackoverflow.com/questions/57548284/grails-4-groovys-date-enhancement-methods-missing) – injecteer May 03 '21 at 17:06

1 Answers1

2

Why is Groovy's date extensions not available in Micronaut?

Groovy's date extension is available in Micronaut. The date extensions may be used in any JVM app (including Micronaut). I expect you are missing a dependency on the groovy-dateutil library, which is the library which provides that method.

You should add a dependency on 'org.codehaus.groovy:groovy-dateutil:3.0.5' to your project.

Jeff Scott Brown
  • 26,804
  • 2
  • 30
  • 47
  • The question at https://stackoverflow.com/questions/57548284/grails-4-groovys-date-enhancement-methods-missing was asked in the context of Grails, not Micronaut, but the exact same issue applies in both contexts. – Jeff Scott Brown Aug 17 '20 at 14:19