title: $datetostring in mongo does not work
body: <p>I have a question that has made me busy for 3 days and still fighting with it: I have mongodb query as follow: </p>
  
  <pre><code> db.test.aggregate([ 
    { 
       $project: { 
           yearMonthDay: { 
                $dateToString: { format: "%Y-%m-%d", date: "$date" } 
           } 
       } 
    } 
  ]) 
  </code></pre>
  
  <p>now I am trying to convert it to java but I really do not know how to convert this line: </p>
  
  <pre><code>yearMonthDay: { 
         $dateToString: { format: "%Y-%m-%d", date: "$date" } 
  } 
  </code></pre>
  
  <p>I tried this code but not working at all: </p>
  
  <pre><code> DBObject project = new BasicDBObject("_id", 0);
   DBObject format = new BasicDBObject("format","%Y-%m-%d");
   format.put("date", "$date");
   DBObject formattedDate = new BasicDBObject("$dateToString",format);
   project.put("yearMonthDay",formattedDate);
  </code></pre>
  
  <p>but I get the following error: </p>
  
  <blockquote>
    <p>com.mongodb.CommandFailureException: </p>
    
    <p>{ "serverUsed" : "...." , "errmsg" : "exception: invalid<br>
    operator '$dateToString'" , "code" : 15999 , "ok" : 0.0}</p>
  </blockquote>
  
  <p>Does anyone have any idea?</p>