I need to save json object in mongodb having dates, here is sample json:
{
"modifiedon": {
"$dateFromString": {
"dateString": "2017-02-08T12:10:40.787"
}
},
"modifiedby": "ramsha-GRM1 Ambreen",
"id": 537
}
I expect 'modifiedOn' value should save as
"modifiedon": ISODate("2017-02-08T12:10:40.78")
Here is a code to insert json into mongodb using java
String json = {<JSONVALUE>};
mongoOperations.insert(json,"risk");
But MongoOperations save JSON without process $dateFromString which is a date formatted in MongoDB. Any leads are highly appreciated thanks
after hit an trial above issue has been resolved by modifying input JSON object as
{ "modifiedon": { "$date": "2020-09-30T11:32:58.000Z" }, "modifiedby": "ramsha-GRM1 Ambreen", "id": 229 }
AND it is saved in MongoDB as date object and I am able to query against date