javamicrostrategy

Command manager procedure in MicroStrategy not converting to date


I am running below command manager procedure in Microstrategy but it does not convert the string into date, tried lot of options. Can someone please assist?

*********** PROCEDURE***************************************

String sQuery = "LIST ALL SUBSCRIPTIONS FOR SCHEDULE \"" + sScheduleName + "\" FOR PROJECT \"" + projectName + "\";";
ResultSet oSubs=executeCapture(sQuery);
oSubs.moveFirst();

while(!oSubs.isEof()){
String sSubsName = oSubs.getFieldValueString(DisplayPropertyEnum.GUID);
ResultSet RecList = executeCapture("LIST ALL PROPERTIES FOR SUBSCRIPTION GUID " +sSubsName+ " FOR PROJECT \"projectname\";");
RecList.moveFirst();
while(!RecList.isEof()){
ResultSet oResultSetSubProps = (ResultSet)RecList.getResultCell(SUBSCRIPTION_RESULT_SET).getValue();
oResultSetSubProps.moveFirst();
while(!oResultSetSubProps.isEof())
{
String d1 = oResultSetSubProps.getFieldValueString(DisplayPropertyEnum.EXPIRATIONDATE);

// the below few lines in red return nothing, its unable to convert to Date as it is unable to recognize the Expiration date in the String format.


java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("M/dd/yyyy");
String dateInString = d1;
Date date = formatter.parse(dateInString);
printOut(formatter.format(date));


oResultSetSubProps.moveNext();
}
RecList.moveNext();
}
oSubs.moveNext();
}

Solution

  • This worked for me. The string was neither empty, nor null and no even blank but it would still not parse it so i had to use the length of the string.

    java.text.DateFormat formatter = new    java.text.SimpleDateFormat("M/d/yyyy",Locale.US);
         String dateInString = d1;
        if(d1.trim().length()>0)
        {
        Date date = formatter.parse(dateInString);
        if(todaydate.compareTo(date)>0)
        {
        printOut(name+";"+formatter.format(date));
         }
        }