cancel
Showing results for 
Search instead for 
Did you mean: 

Date comparison in Redwood Script

Former Member
0 Kudos

Hi,

I want to compare todays date with what user selects the date as part of in parameter for the JOB.


Please find the below logic which i am using, but Iam getting error for the same.  Please let me know how to compare the date between Java.util.Date and com.redwood.scheduler.api.date.DateTimeZone.


TO_DATE we are getting as in parameter

currentDate = new Date();

if(TO_DATE.before(currentDate)){

    //Logic

}

I am getting the below error.

JCS-102183: Compile failed for Job Definition Z_Script_Audit_Security_NC2 (Latest Version): Z_Script_Audit_Security_NC2.java:user code 105:25:after(com.redwood.scheduler.api.date.DateTimeZone) in com.redwood.scheduler.api.date.DateTimeZone cannot be applied to (java.util.Date) if(TO_DATE.after(currentDate){

Thanks

Nidhish

Accepted Solutions (0)

Answers (1)

Answers (1)

h_carpenter
Active Contributor
0 Kudos

Hi Nidhish,

You are comparing two different things, you need both to be either Date or DateTimeZone.

Two options:

  • Change the job parameter to be of type Date
  • Change your code to create a DateTimeZone instead of a Date, see code below:

TO_DATE we are getting as in parameter

DateTimeZone currentDate = new DateTimeZone();

if(TO_DATE.before(currentDate)){

    //Logic

}

Note: DateTimeZone is safer than Date if you use different time zones.

Regards,

HP