2017-05-03 98 views
0

我正在使用MongoCursor遍歷集合並檢索changeDate(以ISODate格式)。但是,使用mongocursor會以不同的格式返回數據。是否有可能以ISODate格式檢索changeDate。無法獲得ISODate格式結果

這裏是文檔結構和我的代碼。請讓我知道如何以ISODate格式檢索日期。

MongoCursor<Document> cursor = col.find().iterator(); 

     while (cursor.hasNext()) { 

      Document doc = hCursor.next(); 
      Object changeDate = doc.getDate("ChangeDate"); 
      System.out.println(changeDate); 
     } 

CHANGEDATE在格式返回:星期三5月5日18點46分58秒EDT 2017採集數據的

結構:

{ 
    "_id" : ObjectId("590a253fe4b05069ea21776b"), 
    "changeDate" : ISODate("2017-05-03T18:46:58.577Z"), 
    "createdBy" : 「abc」, 
    "lastChangedBy" : 「xyzzy」 

} 

我想要的輸出作爲2017-05 -03T18:46:58.577Z。 我嘗試使用喬達日期,但沒有覺得它非常有用。 欣賞任何幫助!

+0

什麼是你的java版本? – Veeram

+0

Java 8,Mongo java驅動 - 3.4.2 – Saurabh

回答