title: ReactiveMongo: Need to convert java.time.LocalDate to reactivemongo.bson.BSONDateTime
body: <p>My requirement is to set <code>BSONDateTime</code> to specific data only. From <code>java.util.Date</code> i found exact data, but when trying to convert in <code>BSONDateTime</code> my output is wrong. Following is my code for convert: </p>
  
  <pre><code>val currentDate: LocalDate = LocalDate.now();
  val milliSeconds: Long = currentDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
  new BSONDateTime(milliSeconds);
  </code></pre>
  
  <p><strong>Output</strong>: </p>
  
  <p><strong>Aspected</strong>: Fri Oct 16 2015 00:00:00</p>
  
  <p><strong>Actual</strong>: Fri Oct 15 2015 18:30:00</p>
  
  <p><strong>Update Question</strong></p>
  
  <p>My Basic requirement is that, i want set and compare my date in mongodb data using query. Like: my mongodb document have following structure</p>
  
  <pre><code>{
   "_id" : ObjectId("561e62892d0000e98ec782c3"),
   "addedOn" : ISODate("2015-10-14T14:11:21.361Z"),
   "expiredOn" : ISODate("2015-10-30T00:00:00.000Z")
  }
  </code></pre>
  
  <p><em>My First Query requirement</em> is set expire date to current date using below code: </p>
  
  <pre><code> def currentDateOnly: BSONDateTime = {
    val currentDate: LocalDate = LocalDate.now();
    val milliSeconds: Long = currentDate.atStartOfDay().atZone(ZoneOffset.UTC).toInstant().toEpochMilli();
  
    logger.info("currentDateOnly Conversion: "+currentDate); 
    new BSONDateTime(milliSeconds);
  }
  </code></pre>
  
  <p>From this code, i found current date with 12 am morning time. I am converting date to <code>milliSeconds</code> and create <code>BSONDateTime</code> object and set the value using reactive mongo query as below: </p>
  
  <pre><code>$set(propertyName -&gt; CustomUtility.currentDateOnly) // this is just a set par of update statement.
  </code></pre>
  
  <p><em>My Second Query requirement</em> is to match "expiredOn" date using following query: </p>
  
  <pre><code>$doc("expiredOn" $gte CustomUtility.currentDateOnly);
  </code></pre>
  
  <p>Now, when i set the date in database, my mongo db store invalid value of date, that i also mention above like: </p>
  
  <p><strong>Output</strong>: </p>
  
  <p><strong>Aspected</strong>: Fri Oct 16 2015 00:00:00</p>
  
  <p><strong>Actual</strong>: Fri Oct 15 2015 18:30:00</p>
  
  <p>I need to store specific data and compare query with specific date. </p>