MicroStrategy中的命令管理器过程未转换为日期

时间:2017-03-08 22:03:24

标签: java microstrategy

我在Microstrategy中运行命令管理器程序,但它没有将字符串转换为日期,尝试了很多选项。有人可以帮忙吗?

*********** 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();
}

1 个答案:

答案 0 :(得分:0)

这对我有用。该字符串既不是空的,也不是null,甚至没有空白但它仍然不会解析它所以我不得不使用字符串的长度。

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));
     }
    }