MongoDB Date handling issue

994 views
Skip to first unread message

Tej Kotthakota

unread,
Dec 17, 2015, 3:23:12 PM12/17/15
to mongodb-user
My class (to be persisted in Mongodb) has java Date() fields. My understanding is 
java.util.Date is stored as ISODate() in Mongo. However I noticed that  it is stored as 
NumberLong("1450210326397").
Also, noticed that I am able to persist the my class object however when I tried to fetch 
from my Java application I get below exception. Any thoughts on what could be wrong?

Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.Date out of START_OBJECT token
Message has been deleted
Message has been deleted

Sql Daddy

unread,
Feb 23, 2016, 7:44:27 AM2/23/16
to mongodb-user


Hello,

I have got your point, I think You have done mistake in your date format  I am sharing URL here by following that You will resolve your error. Please follow this link

mongodb saves datetime as "UTC DateTime", which you can refer to the following link.

Dates - MongoDB

To use the date you stored, just convert it to you local time. you will get the original.

To know more about SSIS Mongodb Source Go through link.

 

Ankur Raina

unread,
Mar 2, 2016, 1:17:36 AM3/2/16
to mongodb-user

Hi Tej,

Looking at your question, it seems that the issue is somewhat similar to one mentioned in this StackOverflow: How to store Date field as ISODate() using jackson in MongoDB.

However, if this doesn’t help, please post few snippets of your code and specify the MongoDB java driver version that you are using.

Regards

Ankur

Reply all
Reply to author
Forward
0 new messages