Add zone Time to my field date of type String

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>

And here is my expression :


Error message: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: $P{DateFormatter}.format($F{createDateTime})

salma.aboumzrag's picture
Joined: Feb 17 2023 - 3:21am
Last seen: 1 month 4 weeks ago

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 for direct access to our technical support teams offering guaranteed response times.

arai_4 - 1 month 4 weeks ago

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 ?

salma.aboumzrag - 1 month 4 weeks ago

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.

sanderse's picture
Joined: Jul 31 2017 - 3:51pm
Last seen: 2 days 4 hours ago