Sads
Sads

Reputation: 557

Sending parameters to report from Java code

I need to send a timestamp value as parameter from java to JR report. I tried the following code but I'm getting a blank report.

My JRXML File: `

` The report works fine with normal date parameter but fails to display with Time-stamp value.

My Java code : `

I tried various values of timestamp Ex: (new java.sql.Timestamp(2013-02-27) but it is not working.

Upvotes: 0

Views: 873

Answers (1)

Anuj Patel
Anuj Patel

Reputation: 17839

Use:

new SimpleDateFormat("yyyy-MM-dd").parse("2012-01-01");

Simply putting:

new Date(2012-01-01);

would give definitely wrong date, probably EPOCH start date.

Ensure it's MM not mm when parsing your date for month. See SimpleDateFormat javadoc

EDIT

See the image. The date your default values will generate is around 1970. Hence your Between Condition will get all the values between 1970 to Today.

enter image description here

EDIT : 2

In my opinion You are setting wrong parameter in Table's datasource.

Instead of setting From_Date & To_Date from Fields set them as parameter from the main report itself.

Refer Image.

enter image description here

Upvotes: 1

Related Questions