Reputation: 65
I am getting this error msg in my Eclipse with latest Groovy installed.
Exception in thread "main" groovy.lang.MissingMethodException: No signature of method: java.util.Date.parse() is applicable for argument types: (String, String) values: [d/M/yyyy H:m:s, 28/09/2010 16:02:43]
Possible solutions: parse(java.lang.String), wait(), clone(), grep(), any(), use([Ljava.lang.Object;)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:70)
at org.codehaus.groovy.vmplugin.v7.IndyGuardsFiltersAndSignatures.unwrap(IndyGuardsFiltersAndSignatures.java:175)
at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:234)
at GroovyLearn.main(GroovyLearn.groovy:222)
String theDate = "28/09/2010 16:02:43";
def newdate = new Date().parse("d/M/yyyy H:m:s", theDate);
Expected Result: Tue Sep 28 16:02:43 CEST 2010
Actual Result: got error that parse does not work properly
Upvotes: 5
Views: 22342
Reputation: 171094
parse
is a static method on Date
Instead of
def newdate = new Date().parse("d/M/yyyy H:m:s", theDate)
You need to do
def newdate = Date.parse("d/M/yyyy H:m:s", theDate)
Upvotes: 6