0
votes

I am trying to use a filter by date like below.

// I am using the Kotlin language
Criteria.where("date").lte(Date());

but instead of using the ISO format like "2015-05-16T07:55:23.257Z", spring data mongodb generate below query

{ "date" : { "$lte" : { "$date" : 1565820000000 }}}
1
Although following link is for spring elasticsearch data it is likely that your problem is related and the solution is the same. Mapping and Jackson serializer: stackoverflow.com/questions/32042430/… - Jorge Campos
thanks Jorge. the problem is that the query is generated before I specify the class Type. mongoOperations.find(query, SpecifiedClass::class.java) - HARBI Hamid
Nice that you figure it out. Please add your solution as an answer and mark it as accepted it may help others in the future. Don't forget to add some relevant code to explain it. - Jorge Campos
sorry Jorge, but I did not solve the problem. I only pointed out the problem of your suggestion. - HARBI Hamid
to be clear. I tried to set the timestamp date serialization to false in the Spring boot configurations but it didn't solve anything. - HARBI Hamid

1 Answers

0
votes

the generated query is in BSON format, which implies that the transformation of the date to it's ISO format is done by MongoDB and not by spring