rfolkerts Posted June 27, 2009 Share Posted June 27, 2009 Hi,I'd like to print a report using a custom DataSource that delivers data being backed by (Hibernate) PoJos whose Dates are mapped to org.joda.time.DataTime.While I can specify the org.joda.time.DateTime Class for the definition of the field, i.e.<field name="cd.datePublished" class="org.joda.time.DateTime"/>However, in the TextFieldExpression the class cannot be freely set but must be chosen from an Enumeration in the Schema. I tried java.lang.String and java.util.Date but will get Runtime Exceptions then :-(<textField> <reportElement height="20" width="80" x="0" y="0" /> <textElement /> <textFieldExpression class="java.lang.String"><![CDATA[$F{cd.datePublished}]]></textFieldExpression></textField>I googled and searched "The Definitive Guide to JasperReports" and this Forum but didn't find a hint. Would be cool if someone had a hint for this!MTIA!Cheers,_ralf_ Link to comment Share on other sites More sharing options...
rfolkerts Posted June 29, 2009 Author Share Posted June 29, 2009 Hi, just an Update... As I'm using a custom DataSource I changed that to return the "toDate()" of an Object of Type org.joda.time.DataTime. This way I can keep the DataTime-Objects in the PoJos but use Date in Reports. However, it would be nice if there was (I'm sure there is?) a way to access the DateTime natively from withing a JR.... Cheers, _ralf_ Link to comment Share on other sites More sharing options...
Solution lucianc Posted June 29, 2009 Solution Share Posted June 29, 2009 JR text fields do not know how to display org.joda.time.DataTime objects, so you have to explicitly convert them to one of the known types. You can do $F{..}.toDate() in the text field expression if you don't want to change your objects.Regards,Lucian Link to comment Share on other sites More sharing options...
rfolkerts Posted June 29, 2009 Author Share Posted June 29, 2009 Hi Lucian, thank you *very* much for your reply! Seems I was stupidly searching for the wrong Information (all the time I searched for "custom data types" instead of having an additional look into the Features of the JRTextField :-( This (JRTextField) solution is much better then my work-around! Thanks again, cheers, _ralf_ 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