方法java.util.Date.parse()的签名不适用于参数类型
我在安装了最新Groovy的Eclipse中收到了这个错误消息方法java.util.Date.parse()的签名不适用于参数类型,java,groovy,Java,Groovy,我在安装了最新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 so
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);
预期结果:2010年9月28日星期二16:02:43
实际结果:出现错误,解析无法正常工作parse
在日期是一个静态方法
而不是
def newdate = new Date().parse("d/M/yyyy H:m:s", theDate)
你需要做什么
def newdate = Date.parse("d/M/yyyy H:m:s", theDate)
Date.parse()?这在Groovy中应该可以工作:@Zephyr-我传递了1个字符串-在eclipse外部对它进行了测试,它工作得很好,也许我的版本不对this@ndueck-检查这个-解析函数是交叉的,我认为问题现在出现在eclipse中,因为我在groovyConsole中测试了它,它工作得很好-我测试了两个选项,没有一个有效