Pattern format ignored on textfield using joda.time value

0

I previously had an issue of how to stop local timezone conversion for DOB fields.  User darth_fader provided a quick and simple solution.  However, now the textfield pattern is being ignored.   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>

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

1 Answer:

1
Put this in your text field expression:
 
org.joda.time.format.DateTimeFormat.forPattern("MM/dd/yyyy").print(new org.joda.time.DateTime($F{dob}).withZone(org.joda.time.DateTimeZone.forID("UTC")))
 
There may be a way to preserve the format attribute on the text field tag, if that's a necessity let me know
 
 
darth_fader's picture
Joined: Mar 7 2010 - 9:45pm
Last seen: 10 hours 12 min ago
Feedback
randomness