2017-03-09 67 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> 
相关问题