以下是我的jrxml的摘录:
<textField>
<textFieldExpression><![CDATA["Exported on " + new java.text.SimpleDateFormat("dd-MMM-yyyy HH:mm:ss z").format(new java.util.Date(), java.util.Locale.US)]]></textFieldExpression>
</textField>
在使用Jaspersoft Studo 6.0.4编译时,我得到了这个错误。最后:
Errors were encountered when compiling report expressions class file:
1. The method format(Date, StringBuffer, FieldPosition) in the type SimpleDateFormat is not applicable for the arguments (Date, Locale)
value = "Exported on " + new java.text.SimpleDateFormat("dd-MMM-yyyy HH:mm:ss z").format(new java.util.Date(), java.util.Locale.US); //$JR_EXPR_ID=28$
这似乎很奇怪,因为SimpleDateFormat
没有任何format(Date, StringBuffer, FieldPosition)
方法!
答案 0 :(得分:0)
Locale
参数放在正确的方法上,这是正确的jrxml:
<textField>
<textFieldExpression><![CDATA["Exported on " + new java.text.SimpleDateFormat("dd-MMM-yyyy HH:mm:ss z", java.util.Locale.US).format(new java.util.Date())]]></textFieldExpression>
</textField>