2017-03-08 48 views
0

我在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(); 
} 
+0

我越來越無法解析的日期:「」雖然我在您正在使用什麼版本的MicroStrategy的M/dd/yyyy格式 – user3438791

+0

的正確格式正在進入? –

+0

我正在使用10.4。儘管我能弄明白。感謝您的登記。 – user3438791

回答

0

這對我有效。該字符串既不是空的,也不爲空,甚至沒有空白,但它仍然不會解析它,所以我不得不使用字符串的長度。

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)); 
    } 
    } 
相關問題