Insert LocalDateTime with MongoTemplate in Azure Cosmos DB

221 Views Asked by At

I'm saving a simple java object to Azure Cosmos DB ( mongo API ) from a spring boot application, using mongoTemplate. The insert works, but I'm having some problem with the dates; my object has a LocalDateTime property: when I save the object to my local MongoDB (NO COSMOS) the date appears like this:

"timestamp": 2022-08-01T00:00:00.000+00:00

Instead, when I save the object to Cosmos db, the date appears like this:

"timestamp" : {
    "$date" : 1659305160000
},

What I want is to save the date in the same format as MongoDB also on Cosmos.
Any suggestions?

0

There are 0 best solutions below