2017-03-09 65 views
1

我想在我與格式的報告顯示java.time.LocalDate如何在文本字段中格式化java.time.LocalDate?

<textField pattern="EEEEE dd MMMMM yyyy"> 
    <reportElement x="64" y="0" width="150" height="20" uuid="5e003c53-2327-4f75-9adf-831a3bb494ff"/> 
    <textElement verticalAlignment="Middle"> 
     <font isBold="true" isUnderline="true"/> 
    </textElement> 
    <textFieldExpression><![CDATA[$F{dateFacture}]]></textFieldExpression> 
</textField> 

但我得到一個日期,如:2017年3月9日。是否由於java.time.LocalDate類型?

+0

。我不知道賈斯珀報告對這個問題的回答。在純Java中,您可以使用'LocalDate.format(DateTimeFormatter)'。 –

+2

解決方案:$ F {dateFacture} .format(java.write.Formatter.ofPattern(「EEEE dMMMM yyyy」)) – thomas

+0

@PetterFriberg,該問題的答案解釋瞭如何在Java中設置LocalDateTime的格式 - Jasper報告中不是'LocalDate'。問題標籤爲jasper-reports,而不是java,這可能意味着Jasper報告上下文是提問者的問題?托馬斯最好說明一下。 –

回答

0

只是爲了記錄,這個問題已經回答了,下面是提問者報告的註釋的解決方案:它看起來像`LocalDate.toString()`好嗎結果

<textFieldExpression> 
    <![CDATA[$F{dateFacture}.format(java.time.format.DateTimeFormatter.of‌​Pattern("EEEE d MMMM yyyy"))]]> 
</textFieldExpression> 
相關問題