POJO:
public class POJO {
private String IdpUploadId;
private String type;
private String userId;
private String email;
private String cnsTenantId;
private Date createdOn;
private String createdBy;
private Date updatedOn;
private String updateBy;
}
Here the Date is coming from the library java.util.date. When I insert the above pojo class into mongodb, the date fields are stored properly as "2022-06-13T14:20:51.511+00:00". However when I retrieve it, the date is being returned in the integer format like below. Check createdOn and updateBy fields.
{
"type": "custom",
"userId": "XX",
"email": null,
"cnsTenantId": "XX",
"createdOn": 1655130051511,
"createdBy": "USERANA002",
"updatedOn": 1655130051511,
"updateBy": "XX",
"idpUploadId": "4961c827-0626-465e-9ec6-fd392c69e08b"
}
The above data is retrieved in this way: MongoCollection collection = database.getCollection("collectionName", POJO.class);
How to retrieve the date in the proper date format ?