03-08-2006 06:52 AM - edited 03-13-2019 11:34 PM
Hi,
I have a CRS script that reads an XML file and checks holiday dates. I need to check dates offset from the current date, so Im using the java Calendar object (java.util.Calendar). For example, lets say I want the date 4 days back from today. Using a Set step, I code;
{java.util.Calendar cal = java.util.Calendar.getInstance();
cal.add(cal.DATE, -4 );
return cal.getTime();}
Heres my problem, I need the offset to be a variable from the script. In my script I have defined nDateOffset as an int and set to the value -4. But when coded like this;
{java.util.Calendar cal = java.util.Calendar.getInstance();
cal.add(cal.DATE, nDateOffset);
return cal.getTime();}
The script fails with NullPointerException. Does anyone have a suggestion or solution?
Thanks
03-08-2006 07:54 AM
Did you debug and see which line it is failing at? The cal.add line or cal.getTime() line?
I don't know if you can get the currentTime for 4 days back. The getTime is the current time. So, it might be failing at the getTime line.
Debug and let me know.
03-08-2006 08:24 AM
The java code executes as expected and returns the date 4 days back. It only fails when "-4" is changed to the script variable "nDateOffset". On a side note, if I mark nDateOffset as Final, the code will work, but this defeats the purpose of the variable.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide