没有方法的签名:java.util.Date.parse() 适用于参数类型



我在安装了最新Groovy的Eclipse中收到此错误消息。

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);

预期成果: Tue Sep 28 16:02:43 CEST 2010

实际结果:出现解析无法正常工作的错误

parseDate上的静态方法

而不是

def newdate = new Date().parse("d/M/yyyy H:m:s", theDate)

你需要做的

def newdate = Date.parse("d/M/yyyy H:m:s", theDate)

相关内容

最新更新