AnsweredAssumed Answered

Accessing toCalendar() method from within Groovy

Question asked by GregHuxley8361 on Jun 12, 2014
Latest reply on Jun 13, 2014 by GregHuxley8361
I'm trying to use the method in a Groovy custom scripting step, see below, but my script is failing with the error: No signature of method: java.util.Date.toCalendar() is applicable for argument types: () values: {}

It appears the toCalendar() method isn't available in the version of Groovy Boomi uses.  Does anybody know how I can gain access to this method?

The script I'm trying to run is:

     import java.util.Properties;
     import com.boomi.execution.ExecutionUtil;
     import java.util.Calendar.*;
     import java.util.Date.*;

     logger = ExecutionUtil.getBaseLogger();

     int monthsToSubtract = 6;

     for( int i = 0; i < dataContext.getDataCount(); i++ ) {
       InputStream is = dataContext.getStream(i);
       Properties props = dataContext.getProperties(i);

       propValue = ExecutionUtil.getProcessProperty("a3e0bf3d-fb9d-4d63-88d9-373fe8ff3e41","8cbdc23f-55f4-4a3e-b0ab-063385b5294d")"Selection date: " + propValue);

       def IN_selectionDate  = new Date().parse("yyyy-MM-dd'T'HH:mm:ss", propValue);
       def Calendar sd = IN_selectionDate.toCalendar();
       sd.add(Calendar.MONTH, -monthsToSubtract);
       def OUT_selDate6mth = new Date().parse("yyyy-MM-dd'T'HH:mm:ss.SSS", sd.format("yyyy-MM-dd'T'HH:mm:ss.SSS") );

       ExecutionUtil.setProcessProperty("a3e0bf3d-fb9d-4d63-88d9-373fe8ff3e41","8f59e2a3-73b0-4e45-ae6f-606a0e687952", OUT_selDate6mth.format("yyyy-MM-dd'T'HH:mm:ss.SSS")

       dataContext.storeStream(is, props);