formatting dates from a text file and passing them to a Scrapeable File

Please review this attempt at an interpreted java script:

dates = dataRecord.get("TheWholeKaboodle");
String [] dates = dates.split(" ");
for ( int i = 0; i < dates.length; i++ ) { // loop over each element
String date = dates[i];
//sutil.reformatDate( "01/01/2010", "MM/dd/yyyy", "yyyy-MM-dd" );
date = sutil.reformatDate(date, "MM/dd/yyyy", "yyyyMMdd" );
session.setVariable("date", date);
//session.scrapeFile("details");
session.log(date); //I hoped this would output reformatted 'date' to the session log in 'debug' mode. Apparently this is not how that works.
}

The session first reads a text file containing a range of data fields from Excel, f.e. 1/1/2011, 1/2/2011. So far so good.

I hope to loop through these values, change each to the "20110101" format, then pass it into the URL of a Scrapeable File.

In the meantime I ran the script as is, hoping to see reformatted data fields in the session log but there is no output.

Best,

Mechnik

It looks like you get the

It looks like you get the concept. In fact, I think the script you show should work. All I can suggest is some more logging to track down the problem:

String[] dates = dataRecord.get("TheWholeKaboodle").split(" ");
session.log("There are " + dates.length + " dates");
for (i=0; i<dates.length; i++)
{
        session.log("Reformating date " + i);
        date = dates[i];
        session.log("Starting with date: " + date);
        newDate = sutil.reformatDate(date, "M/d/yyyy", "yyyyMMdd" );
        session.log("Reformatted to: " + newDate);
        session.setVariable("date", newDate);
        //session.scrapeFile("details");
}

Thank you!

Thank you!