I added this param:
<parameter name="DateFormatter" class="java.text.DateFormat" isForPrompting="false">
<defaultValueExpression><![CDATA[$P{REPORT_FORMAT_FACTORY}.createDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", $P{REPORT_LOCALE}, $P{REPORT_TIME_ZONE})]]></defaultValueExpression>
</parameter>
And here is my expression :
<textFieldExpression><![CDATA[$P{DateFormatter}.format($F{createDateTime})]]></textFieldExpression>
Error message: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: $P{DateFormatter}.format($F{createDateTime})
1 Answer:
The "java.text.DateFormat.format()" method is used to format a Date into a specific formatted string. You seem to be trying to take a string field and translate it into a Date" object. This requires different java code.
To format a date into a specific string format, use the "Pattern" or the "PatternExpression" property of the text field.
Thank you for posting to the Jaspersoft Community. Our team of experts has read your question and we are working to get you an answer as quickly as we can. If you have a Jaspersoft Professional Subscription plan, please visit https://support.tibco.com/s/ for direct access to our technical support teams offering guaranteed response times.
Yes I used a new java code for my field : $P{DateFormatter}.format(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse($F{createDateTime}))
but i can't set the time zone to "Europe/paris", however the time zone of my date is +00.
can you help me ?