我在grails中有这段代码
DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm");
formatter.print(new DateTime()) // It's null
formatter.with{
delegate.invokeMethod('print', new Datetime())
} // It's null
InvokerHelper.invokeMethod(formatter, 'print', new DateTime()) //It's null
我发现grails调用" invokePojoMethod"方法,metaClass是ExpandoMetaClass,它包含' print'方法
static Object invokePojoMethod(Object object, String methodName, Object arguments) {
MetaClass metaClass = InvokerHelper.getMetaClass(object);
return metaClass.invokeMethod(object, methodName, asArray(arguments));
}
如何调用joda的DateTimeFormatter方法' print'直接解决这个名称冲突?