Jump to content
Changes to the Jaspersoft community edition download ×

How to display org.joda.time.LocalDate and org.joda.time.LocalDateTime


vhmangaiha

Recommended Posts

Hi all,

I am using Jaspersoft Studio 5.6.0 Final

1) I am using Collection of JavaBeans as Data Adapter, testing is successful

2) I am including joda-time-2.1.jar and my jar files in the build path

3) From the data preview , all the data is coming properly

4) I have two fields which is of org.joda.time.LocalDate and org.joda.time.LocalDateTime.

    <field name="seizureAndArrest" class="org.joda.time.LocalDateTime">        <fieldDescription><![CDATA[seizureAndArrest]]></fieldDescription>    </field>    <field name="dateOfDisposal" class="org.joda.time.LocalDate">        <fieldDescription><![CDATA[dateOfDisposal]]></fieldDescription>    </field> [/code]

  In the display part in my jrxml

            <textField>                    <reportElement x="124" y="0" width="61" height="35" uuid="a13f37f2-ae19-48a1-8348-5b48a3f3b834"/>                    <textFieldExpression><![CDATA[$F{seizureAndArrest}]]></textFieldExpression>            </textField>            <textField>                <reportElement x="682" y="0" width="57" height="35" uuid="12baa0d8-4f66-47bb-9565-e6967130b986"/>                <textFieldExpression><![CDATA[$F{dateOfDisposal}]]></textFieldExpression>            </textField> [/code]

When i run in my JasperSoft Studio , i get the following errors


net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :
    Source text : $F{seizureAndArrest}
    at com.jaspersoft.studio.editor.preview.view.control.ReportControler.fillReport(ReportControler.java:466)
    at com.jaspersoft.studio.editor.preview.view.control.ReportControler.access$18(ReportControler.java:441)
    at com.jaspersoft.studio.editor.preview.view.control.ReportControler$4.run(ReportControler.java:333)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :
    Source text : $F{seizureAndArrest}
    at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:263)
    at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:611)
    at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:579)
    at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:1016)
    at net.sf.jasperreports.engine.fill.JRFillTextField.evaluateText(JRFillTextField.java:504)
    at net.sf.jasperreports.engine.fill.JRFillTextField.evaluate(JRFillTextField.java:488)
    at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:259)
    at net.sf.jasperreports.engine.fill.JRFillFrame.evaluate(JRFillFrame.java:149)
    at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:259)
    at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:456)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2067)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:788)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:298)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:152)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:963)
    at net.sf.jasperreports.engine.fill.BaseFillHandle$ReportFiller.run(BaseFillHandle.java:120)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassCastException: org.joda.time.LocalDateTime cannot be cast to org.joda.time.LocalDateTime
    at ExciseCase_1426179567177_530192.evaluate(ExciseCase_1426179567177_530192:225)
    at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:250)
    ... 16 more


 

I also tried  the below in the Expression part but still i am getting different errors each time I run

org.joda.time.LocalDate.parse($F{dateOfDisposal}.toString())org.joda.time.LocalDate.parse($F{dateOfDisposal}.toString("yyyy-MM-dd"))[/code]

If I remove the two fields, all other data are coming correctly...

How can to display this two fields in my report?

Thanks in advance,

Vanlal

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hello!

This line:

Caused by: java.lang.ClassCastException: org.joda.time.LocalDateTime cannot be cast to org.joda.time.LocalDateTime

Looks like if there seems to be a class loading problem. You may want to check if you have joda-time twice in your classpath.

Best Regards, Christian

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...