ioanbalau Posted October 17, 2017 Share Posted October 17, 2017 Hi,In Jasper Studio i have 2 input controls(both java.util.Date). If i try to Preview the report on the same day(Date from: 2017-10-17 02:00 Date To: 2017-10-17 23:00) it works properly.But when i do the same from Java application the hours are not taken into consideration and result into an empty report.If i select the Date From: 2017-10-17 02:00(today) and Date To: 2017-10-18 23:00 it gathers data between 2017-10-17 00:00 to 2017-10-18 00:00.Condition in query: updatedtime between $P{DateFromInputControl} and $P{DateToInputControl}Why hours are not taken into consideration?Thank you,Emi Link to comment Share on other sites More sharing options...
sanbez Posted October 17, 2017 Share Posted October 17, 2017 You should post minimal example (calling report from java with passing parameters)And show part of jrxml with definition parameters and query Link to comment Share on other sites More sharing options...
ioanbalau Posted October 17, 2017 Author Share Posted October 17, 2017 Query in report: select * from table a where b.updatedtime between $P{DateFromInputControl} and $P{DateToInputControl}In Java i used JasperFillManager.fillReport() method. The input controls were formated to java.util.Date formatDefinition in Jasper report:<parameter name="DateFromInputControl" class="java.util.Date"> <parameterDescription><![CDATA[]]></parameterDescription> </parameter> <parameter name="DateToInputControl" class="java.util.Date"> <defaultValueExpression><![CDATA[]]></defaultValueExpression> </parameter>Link to image(calling in java): https://ibb.co/kkrP36 Link to comment Share on other sites More sharing options...
sanbez Posted October 17, 2017 Share Posted October 17, 2017 Java code looks correct. I cant't see value $P{DateFromInputControl}may by your code like this?fillParams.put("DateFromInputControl", dateFrom);fillParams.put("DateToInputControl", dateFrom);Show declaration ( and new () ) for map fillParams and how you put values into this map in java code.Why parameter names starting from upper letter? Link to comment Share on other sites More sharing options...
ioanbalau Posted October 18, 2017 Author Share Posted October 18, 2017 So definition of input parameters:Map<String, Object> inputParameters = prepareInputParameters(inputControls);Image before adding the new parameters:Parameter 'DateFromInputControl': https://ibb.co/hezemRParameter 'DateToInputControl': https://ibb.co/gZMLt6Function prepareInputParameters() returns a Map<String, Object> type(result):result.put(parameterName, parameterValue);return result;After all the input controls were added: https://ibb.co/gzQ26R Link to comment Share on other sites More sharing options...
ioanbalau Posted October 18, 2017 Author Share Posted October 18, 2017 Why to_char(InputParameter) does not contain hours?Image: https://ibb.co/dMbaRR Link to comment Share on other sites More sharing options...
sanbez Posted October 18, 2017 Share Posted October 18, 2017 Probably you executed unnecessary processing of parameters.I don't undersatnd 2 point:1. The input controls were formated to java.util.Date format (3th message)2. Using methos parseParameter ( https://ibb.co/gZMLt6 ) ? Link to comment Share on other sites More sharing options...
Solution ioanbalau Posted October 18, 2017 Author Solution Share Posted October 18, 2017 I found a solution for this. If the Input Parameter is java.util.Date type the hours are not taken into consideration in query(it gets only the date, at least from what i tested).I changed the Input Parameter type to java.sql.Timestamp and now hours are taken into consideration. Thank you! Link to comment Share on other sites More sharing options...
sanbez Posted October 18, 2017 Share Posted October 18, 2017 >> I found a solution for this. If the Input Parameter is java.util.Date type the hours are not taken into consideration in query>> I changed the Input Parameter type to java.sql.Timestamp and now hours are taken into consideration. It is not solution. You have to check your java codeI make test report and it work fine with java.util.Date. My test report shows parameters in title of report with hours !=0. And it uses hours in query correctlyYou have a chance get unexpected errors because your solution hide potentional errors (types casting?, parsing?, ...?)I hope you will find a time to solve this problem in right way.Good luck 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