Page 1 of 1

How to set Date variable for "Tomorrow + 3 hours"

Posted: Thu Jan 09, 2020 8:30 pm
by denis.awfm
Problem:
I have a variable in report, which is of DateTime type.
If I use .AddDays(1.125) it renders fine in Designer.
However, when I publish report as Java, it defaults to current timestamp.

If I try to set up the value via Java code, like this (previously set init by Value in Designer, otherwise it has no effect):

Date dateWithoutTime = new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(dateWithoutTime);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
cal.add(Calendar.HOUR_OF_DAY, 3);
dateWithoutTime = cal.getTime();
report1.setRequestParameters(true);
report1.getDictionary().getVariables().get("vScheduledEnd").setValue(dateWithoutTime);

I get exception inside StimulSoft Java application:
java.text.ParseException: Unparseable date "Thu Jan 09 03:00:00 EET 2020"

Please advice how can I set the value of that variable either in Designer (as expression) or programmatically (via Java code).

I searched for an example, but it was for a String variable, which is not my case (DateTime).
If I try to use .setValueObject method I get same error

Re: How to set Date variable for "Tomorrow + 3 hours"

Posted: Wed Jan 15, 2020 9:34 am
by Vadim
Hello.
We tried Java with 2020.1 version and AddDays() works fine

Re: How to set Date variable for "Tomorrow + 3 hours"

Posted: Wed Jan 15, 2020 11:46 am
by denis.awfm
Hi Vadim.
Indeed in 2020.1 AddDays() does work.
Now, I am still receiving current timestamp for a variable if it is initialized by expression Today.AddDays(1.125), where I would expect next day + 03:00. (like Variable2 in your example from the above).
I mean when it is requested from user (parameter sub window).
Also, how can I achieve correct date and time format in Java (in Designer it is fine) for that variable when asked in a parameter window, it always defaults to US (MM/DD/YYYY HH:MI:SS AM/PM)? I would like to enforce by default the European DD/MM/YYYY HH24:MI:SS format.
Screenshot is attached.
Regards,
Denis.

Re: How to set Date variable for "Tomorrow + 3 hours"

Posted: Wed Jan 15, 2020 12:33 pm
by denis.awfm
Followup:
If I use a "buffer" variable (which is initialized by expression Today.AddDays(1.125)), which is not requested from user, stays on top in Variables section of the Dictionary, and the requested variable is initialized by value of that "buffer" variable, it still displaying current timestamp in Parameters subwindow, therefore this trick does not work.

Re: How to set Date variable for "Tomorrow + 3 hours"

Posted: Thu Jan 16, 2020 2:09 pm
by Vadim
Hello.

We fixed variables in variables panel - will available from next version.

DateTime format in parameters control takes from browser settings, also you can define your own format by StiWebViewerOptions object:
options.getAppearance().setParametersPanelDateFormat()

Re: How to set Date variable for "Tomorrow + 3 hours"

Posted: Thu Jan 16, 2020 8:40 pm
by denis.awfm
Hi Vadim.
Thanks for the answer, I was able to set up date and time format in parameters panel, using:

options.getAppearance().setParametersPanelDateFormat("dd/MM/yyyy HH:mm:ss");

for something like 16/01/2020 22:40:00

Re: How to set Date variable for "Tomorrow + 3 hours"

Posted: Sat Jan 18, 2020 5:36 am
by Andrew
Hello,

Thank you for sharing your knowledge.

Have a nice day!

Re: How to set Date variable for "Tomorrow + 3 hours"

Posted: Thu Feb 13, 2020 10:23 pm
by denis.awfm
Hi Andrew.
In version 2020.2 if I do publish report in Java, stimulsoft*.jar's are not put in the .zip file.
Therefore I cannot test if that has been fixed (I mean the issue where time parameters in Java are defaulting to current timestamp).
Can you please advice how can I test it?
Regards,
Denis.

Re: How to set Date variable for "Tomorrow + 3 hours"

Posted: Thu Feb 13, 2020 11:10 pm
by denis.awfm
Hi Andrew.
I was able to download the latest stimulsoft libraries (*.jar). Just forgot to take off the checkbox in Publish screen.
And now Java window where date parameters are set works as planned (.AddDays() instead of current timestamp).
Thanks,
Denis.

Re: How to set Date variable for "Tomorrow + 3 hours"

Posted: Wed Feb 19, 2020 8:44 pm
by Lech Kulikowski
Hello

We are always glad to help you!
Please let us know if you need any additional help.

Thank you.