I'm using the new MongoDB Scala Driver. When I store a java.util.Date, it is being stored in MongoDB as an Int64 instead of a MongoDB Date. I have some code that looks like this:
implicit val writer = new Writes[Forecast] {
def writes(x: Forecast): JsValue = {
Json.obj(
// ...
"issueDateTime" -> x.issueDateTime // which is a java.util.Date
// ...
)
}
}but what ends up in MongoDB is an Int64, not a Date. How do I get a Date into MongoDB?
(also posted to SO: http://stackoverflow.com/questions/34140698/how-do-i-get-a-date-to-store-as-a-date-in-mongodb-instead-of-an-int64 ]
val newdate = new Date()
val doc: Document = Document("test" -> newdate)