scala-如何从scala调用Java中定义的公共静态方法?
我正在尝试调用scala-如何从scala调用Java中定义的公共静态方法?,scala,Scala,我正在尝试调用org.joda.time.format.DateTimeFormatter#forPattern方法 但下面的方法似乎不起作用 scala> import org.joda.time.format.DateTimeFormatter import org.joda.time.format.DateTimeFormatter scala> DateTimeFormatter.forPattern("yyyyMMdd") <console>:30: erro
org.joda.time.format.DateTimeFormatter#forPattern
方法
但下面的方法似乎不起作用
scala> import org.joda.time.format.DateTimeFormatter
import org.joda.time.format.DateTimeFormatter
scala> DateTimeFormatter.forPattern("yyyyMMdd")
<console>:30: error: value forPattern is not a member of object org.joda.time.format.DateTimeFormatter
DateTimeFormatter.forPattern("yyyyMMdd")
^
scala>import org.joda.time.format.DateTimeFormatter
导入org.joda.time.format.DateTimeFormatter
scala>DateTimeFormatter.forPattern(“yyyyMMdd”)
:30:错误:模式值不是对象org.joda.time.format.DateTimeFormatter的成员
DateTimeFormatter.forPattern(“yyyyMMdd”)
^
任何指示都将不胜感激 Java-Scala互操作性在这样的场景中正常工作。你可能把类名弄错了。根据,没有针对模式的
DateTimeFormatter#
,但是针对模式的DateTimeFormat#
DateTimeFormat.forPattern("yyyyMMdd")
非常有魅力。@battaio非常感谢。