I have a string file FECHA EMISION="2018-03-02"
. I want it to display as "Marzo" (March in Spanish/Italian).
I have to convert $F{FECHA EMISION}.substring(5,7)
in integer, but I don´t know how convert the result 02 to the related month.
I have a string file FECHA EMISION="2018-03-02"
. I want it to display as "Marzo" (March in Spanish/Italian).
I have to convert $F{FECHA EMISION}.substring(5,7)
in integer, but I don´t know how convert the result 02 to the related month.
Try setting this expression to a textField:
DATEFORMAT(new SimpleDateFormat("yyyy-MM-dd").parse($F{FECHA EMISION}), "MMMMM")
The best way to do this is to have a Date
object and then apply a pattern (pattern will allow you to export original data to e.g. excel while displaying it as you like)
To apply a pattern you will need to transform the String into a Date object
new java.text.SimpleDateFormat("yyyy-MM-dd").parse($F{FECHA EMISION})
The pattern is MMMM
see Date and Time Patterns
So the final jrxml will be
<textField pattern="MMMM">
<reportElement x="0" y="0" width="100" height="30"/>
<textFieldExpression><![CDATA[new java.text.SimpleDateFormat("yyyy-MM-dd").parse($F{FECHA EMISION})]]></textFieldExpression>
</textField>
Note: In JasperSoft Studio pattern is a property of the textField, hence you can indicate this directly in Studio.