How to format Date that stores in Map<String,Object> in spring rest as UTC in deserialization?

Viewed 35

I have a user class that has a field with Map<String,Object> type.

public class User {
private Map<String,Object> customFields;
... other fields 
}

When I call the end point that retrieves User Object from database, I see the birth date in long milliseconds and In database the format is as same as endpoint E.G, 1641135600000,.
How can I format the birth date in spring rest deserialization? E.G, 2020-01-05.
Imagine that I call localhost:8080/users/23 I'll get:

{
"id":23,
"customFields":{
"birthdate":1641135600000,
...}
}

I'm using mongo Db 4 for this project. When I query the db, I'll get the same result. Thanks.

0 Answers
Related