Groovy java.util.Date or Java java.util.Date?

I have a Java application running groovy built-in scripts using GroovyClassLoader . Everything works fine until I hit an odd error while passing Java types to groovy script.

My problem is this: I pass java.util.Date as a parameter in a groovy script. I found that groovy java.util.Date has a fantastic clearTime () . However, when I try to call this function, I get this exception:

 groovy.lang.MissingMethodException: No signature of method: java.util.Date.clearTime() is applicable for argument types: () values: [] 

I guess this is because I have a Java date, not a groovy date. Is there a way to convert between them.

I admit that I don't quite understand how groovy seems to be overriding jdk types. (Therefore, I don’t even know if this is the correct terminology to use here.) Please correct me if I am completely mistaken about what happens when you create java.util.Date inside groovy against when you pass one of the functions Java features.

+4
source share
1 answer

Well, I found out about my malfunction here. My test application was tied to groovy 1.8.6 at will, but my main program used 1.6.5 (the function I tried to call was introduced in 1.6.7). Eclipse decided not to launch the new version when updating its pom.xml.

0
source

Source: https://habr.com/ru/post/1402506/


All Articles