I have the following json object:
public class User {
private String name;
@JsonFormat(pattern="dd-MM-yyyy")
private Date birthdate;
}
but I'm thinking of changing it to:
private String birthdate; //mmm...now need to make sure the format is respected..
Problem is that this object has to be saved inside of a DB and then retrieved. Suppose I have an user in the CEST time, while my application's time is UTC, so 2 hours behind.
They send "15-04-1990" (time is implicitely 00:00:00), the system then interprets this date as "14-04-1990"(time is implicitely 10:00:00 PM) due to the 2 hours difference. When they go retrieve the information again they will see 14-04-1990!
Ok, I could just add the sender's timezone to the request. But I don't like it: take a 3rd party residing on the application's country wanting to check some information (for example an helpdesk operator): they would still see the date in the wrong timezone!
So, do you see any problem in receiving the date as string? And if that would be fine how to make sure that the string contains a date formatted in "dd-mm-yyyy"?