2015-04-28 12 views
0

這裏是我的JRXML提取物:如何在JasperReports中顯示具有特定格式和區域設置的日期?

<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.Final編譯時我得到這個錯誤:

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

哎呀我沒有把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> 
相關問題