我在安装了最新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);
Run Code Online (Sandbox Code Playgroud)
预期结果: Tue Sep 28 16:02:43 CEST 2010
实际结果:出现无法正确解析的错误
parse 是一个静态方法 Date
代替
def newdate = new Date().parse("d/M/yyyy H:m:s", theDate)
Run Code Online (Sandbox Code Playgroud)
你需要做
def newdate = Date.parse("d/M/yyyy H:m:s", theDate)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2177 次 |
| 最近记录: |