AnsweredAssumed Answered

Groovy script for simpledateformat (MMddyy)

Question asked by asha120987 on Oct 19, 2018
Latest reply on Oct 22, 2018 by trey.yeager826393

Hello All,


  When am trying to implement code in groovy with MMddyy format am facing unparceable date format can anyone help me on this!! please...


import java.util.Properties;
import com.boomi.execution.ExecutionUtil;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

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

String fileName = props.getProperty("document.dynamic.userdefined.file2");
String days = props.getProperty("document.dynamic.userdefined.Days");

int noofdays=Integer.parseInt(days);
int day=-noofdays;"LOOP ENETERED OVER HERE");

substr = fileName.substring(fileName.length()-17, fileName.length()-10);;
Date date = new Date();
SimpleDateFormat df = new SimpleDateFormat("MMddyy");  //this is the line .....
Date d = df.parse(substr);"filetime"+d);

Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, day);"before checking");"purging time"+cal.getTime());

if (d.before(cal.getTime())) {"deleting1");

props.setProperty("document.dynamic.userdefined.userdate", substr);"deleting");

dataContext.storeStream(is, props);