eddie_4 Posted July 16, 2017 Share Posted July 16, 2017 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? Link to comment Share on other sites More sharing options...
eddie_4 Posted July 16, 2017 Author Share Posted July 16, 2017 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. Link to comment Share on other sites More sharing options...
darth_fader Posted July 16, 2017 Share Posted July 16, 2017 Let me know if you still have issues Link to comment Share on other sites More sharing options...
darth_fader Posted July 16, 2017 Share Posted July 16, 2017 For jasper-server, add the joda time jar file into: YOUR-JASPER-DIRECTORY/WEB-INF/lib 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 Link to comment Share on other sites More sharing options...
darth_fader Posted July 16, 2017 Share Posted July 16, 2017 This solution should get you through it Link to comment Share on other sites More sharing options...
eddie_4 Posted July 17, 2017 Author Share Posted July 17, 2017 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> </textField>[/code] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now