I have created a spring application , where I am sending some date to mongoDB which includes date also. I am using below date pattern.
Date date = new Date();
Calendar cal = Calendar.getInstance();
date = cal.getTime();
I am using getter setter for storing and retrieving the data from mongoDB.
which is of type Date. I am able to store the data fine. But while retrieving it shows java.lang.NullPointerException
. I saw data in mongoDB, date is stored as object.
Any idea how we can store the date as date so we can do query based on timestamp
I have tried
Date date = new Date();
And then pushed the date as it is . No need to change it .