How to set Date variable for "Tomorrow + 3 hours"
-
- Posts: 23
- Joined: Wed Sep 25, 2019 7:19 pm
How to set Date variable for "Tomorrow + 3 hours"
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
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"
Hello.
We tried Java with 2020.1 version and AddDays() works fine
We tried Java with 2020.1 version and AddDays() works fine
- Attachments
-
- var2.PNG (18.6 KiB) Viewed 6655 times
-
- var1.PNG (78.1 KiB) Viewed 6655 times
-
- Posts: 23
- Joined: Wed Sep 25, 2019 7:19 pm
Re: How to set Date variable for "Tomorrow + 3 hours"
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.
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.
- Attachments
-
- No_AddDays_in_parameter_window.PNG (23.66 KiB) Viewed 6653 times
-
- Posts: 23
- Joined: Wed Sep 25, 2019 7:19 pm
Re: How to set Date variable for "Tomorrow + 3 hours"
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.
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.
- Attachments
-
- Variable_vScheduledStart.PNG (29.31 KiB) Viewed 6649 times
-
- Variable_v03.PNG (20.98 KiB) Viewed 6649 times
Re: How to set Date variable for "Tomorrow + 3 hours"
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()
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()
-
- Posts: 23
- Joined: Wed Sep 25, 2019 7:19 pm
Re: How to set Date variable for "Tomorrow + 3 hours"
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
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"
Hello,
Thank you for sharing your knowledge.
Have a nice day!
Thank you for sharing your knowledge.
Have a nice day!
-
- Posts: 23
- Joined: Wed Sep 25, 2019 7:19 pm
Re: How to set Date variable for "Tomorrow + 3 hours"
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.
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.
-
- Posts: 23
- Joined: Wed Sep 25, 2019 7:19 pm
Re: How to set Date variable for "Tomorrow + 3 hours"
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.
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.
-
- Posts: 6254
- Joined: Tue Mar 20, 2018 5:34 am
Re: How to set Date variable for "Tomorrow + 3 hours"
Hello
We are always glad to help you!
Please let us know if you need any additional help.
Thank you.
We are always glad to help you!
Please let us know if you need any additional help.
Thank you.