Search code examples
micronaut

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


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.


Solution

  • 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.