I am using Spring Data MongoDB. When I save some records MongoDb doesn't save correctly my timestamp.
Here is my timestamp field in Spring.
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
private Date timestamp = new Date();
My MongoDB record.
{
"_id": ObjectId("5697a672ce2a8e5347d86afd"),
"batteryLevel": 100,
"beaconClass": 3,
"beaconId": "dsadsa",
"timestamp": ISODate("2016-01-14T13:45:22.702Z")
}
When I log to console my timezone and date I see it is correct.
Eastern European Time
Asia/Istanbul
Thu Jan 14 15:45:22 EET 2016
How can I correct time MongoDB timestamp?
MongoDB stores times in UTC by default, and will convert any local time representations into this form, see the documentation. You will have to compute the original local time in your application logic.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With