How to set Date variable for "Tomorrow + 3 hours"
Posted: Thu Jan 09, 2020 8:30 pm
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