Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Blue

CRS 4.0 - java - add 30 days to current date

Anyone have a sample script for CRS 4.0 that will add 30 days to the current date? I have scripts that will do this in CRS 3.x but the Java steps are no longer there. I understand I can re-create in 4.x but just looking to save a little time.

tia

1 REPLY
Green

Re: CRS 4.0 - java - add 30 days to current date

Sure. I just built this and tested it on 4.0(3)_Build080.

It generates a prompt from a Date object and reads it back. That's today. Then it uses the Calendar class to construct a new Calendar representing right now, adds 30 days, and converts it to a java.util.Date class to return to a variable of Date. It generates the new date prompt and plays it back.

I declare three variables:

dateToday - Date - new Date()

dateTodayPlus30 - Date - null

promptGenerated - Prompt - null

The important bit is done in the expression editor. The "SET" node is used setting the dateTodayPlus30 variable using a block statement as follows:

{

// get right now

java.util.Calendar rightNow = java.util.GregorianCalendar.getInstance();

// add 30 days

rightNow.add(java.util.Calendar.DATE, 30);

// CRS wants a java.util.Date type

return rightNow.getTime();

}

Regards,

Geoff

603
Views
0
Helpful
1
Replies
CreatePlease to create content