Open cleitonsoares opened 3 years ago
For what you need urgent an date value as java.util.Date. Check, if you can also work with a string value for your report.
You need DTINI and DTFIN as Start Date and End Date for your Query - correct? For this is here a solution:
You define both values as String value (in the report and in it's call in the javascript). Then you modify your report query an used not the original date value, you compared values a special date format (which is possible in your database system). Example for MySQL: In the Jasperreport samples you can find the DATARANGE Report. In Case 3 the query select against the OrderDate (as Date value). You can also compare against a String value - use simple DATE_FORMAT(orderdate,"%Y%m%d") as value for compare with a String value. So you can now in the javascript pass a string value as criteria.
Hi, @dcsline thanks for reply.
After spent many time, i'm able to pass java date object to report by this way:
const java = require('java');
const simpleDateFormat = java.import('java.text.SimpleDateFormat');
reportParams[key] = new simpleDateFormat("yyyy-MM-dd HH:mm:ss").parseSync(reportParams[key]);
where reportParams[key] is a JavaScript date string json form request payload;
Hi Cleiton, there are different approaches. For many years it has been my preferred approach to use a timestamp as a string variable. I have not thought of the possibilities offered by the java.import function in this specific case, thank you for your hint.
Hello, i'm trying to pass Date to my report as "data" parameter, but when i print the parameter in my report, it's null;
In node, i'm converting string to Date object and passing in "data":
And in report, i tried to set date parameter as java.uitil.Date, java.sql.Date and java.sql.Timestamp, in any of this cases, the value is printing as null:
I appreciate it if anyone can help me, thanks.