Stop Timezone conversion for one field in report


I have a report that has several dates on it.  The dates are stored in the database in UTC format.  I have the report converting UTC to local report time, however, one of the dates is date-of-birth.  The database field is yyyy-mm-dd 00:00:00.  When the DOB is displayed on the report the date/time is adjusted -4, -5 or -6 hours and displays as the previous day.

How can I keep the DOB from being adjusted to local time?

eddie_4's picture
Joined: Apr 25 2017 - 8:18am
Last seen: 2 months 1 week ago

Let me know if you still have issues

darth_fader - 2 months 1 week ago

Thanks for your response.  I'm still a noob in iReports and although I know C#, Javascript and a slew of other languages, java isn't in my back of tricks.

Would I put code in the field def on the report?  Right now, I'm just using a pattern to format the data.

Will I need to add another library for the Joda-Time libraries?  

Sorry to be a pain, just not up to speed on the architecture of adding code to a specific field.

eddie_4 - 2 months 1 week ago

This solution should get you through it

darth_fader - 2 months 1 week ago
show 1 more...

That answer helped me.  Thank you.  The date is now correct.  However it is ignoring the pattern.  I have MM/dd/yyyy for the pattern but the report is formatting as yyyy-MM-ddT00:00:00.


<textField pattern="MM/dd/yyyy" isBlankWhenNull="true">
    <reportElement x="123" y="0" width="88" height="20" uuid="40bfec19-25c5-4807-801f-464034799729"/>
    <textElement>     <font fontName="Arial" isBold="false"/>    </textElement>
    <textFieldExpression><![CDATA[new org.joda.time.DateTime($F{dob}).withZone(org.joda.time.DateTimeZone.forID("UTC"))]]></textFieldExpression>

eddie_4 - 2 months 1 week ago

1 Answer:


For jasper-server, add the joda time jar file into:


You'll notice other jar files there as well. WIll require a server restart to take effect.


If you're just using IReport/Jasper Studio, you'll need to add the jar to the class path, something along the lines of

Tools-->Option-->Classpath-->Add JAR



The code reference will be something like; see the ref to the example field below? You'll probably be able to make a go of it after this example:

<textFieldExpression><![CDATA[new org.joda.time.DateTime($F{YOUR_DATE_FIELD}).withZone(org.joda.time.DateTimeZone.forID("UTC"))]]></textFieldExpression>
It may be easier to add this in through the expression editor in IReport/Jasper Studio.
let me know if you run into any issues
darth_fader's picture
Joined: Mar 7 2010 - 9:45pm
Last seen: 10 hours 17 min ago