Using Spring Boot 1.5.4.RELEASE
and Mongo driver 3.4.2
.
I want to store LocalDate
in mongo DB
, but I am facing a weird problem:
LocalDate startDate = LocalDate.now();
LocalDate endDate = LocalDate.of(2020,12,01);
System.out.println("---- StartDate : ---"+startDate);
System.out.println("-----End Date : ----"+endDate);
repository.save(new Person("Mehraj","Malik", startDate, endDate));
Output on console:
---- StartDate : ---2017-08-26
-----End Date : ----2020-12-01
But In MongoDb it is storing incorrect dates.
Following is the json from MongoDb:
"startDate" : ISODate("2017-08-25T18:30:00.000Z"),
"endDate" :ISODate("2020-11-30T18:30:00.000Z")
Also, I have noticed that the stored time is also incorrect according to Indian time.
Why the dates are correct on console but not in MongoDB and how to resolve this problem?