How do I get a Date to store as a Date in MongoDB instead of an Int64?
问题 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? 回答1: If you are using the latest MongoDB Scala Driver