I want to insert a DateTime into MongoDB from Java. Essentially I want the following object:
{
"_id" : ".....",
"ts": ISODate(".....")
}
How can I create this from a Java Object with MongoDB API?
You can do it as follows :
DBCollection coll = ...
coll.insert(new BasicDBObject("ts", new Date()));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.