Reputation: 26067
I am using below in my Customer entity to map Date
field
@Temporal(TemporalType.DATE)
@Column(name = "birthdate")
@DateTimeFormat(pattern = "dd-MM-yyyy")
private Date birthDate;
But still BirthDate
is saved in yyyy-MM-dd
format. I have tried setting in setter method for field birthDate
using DateFormat, but still same response.
Database is Mysql, column is of type Date
.
I wish to set the value in dd-MM-yyyy
format.
Upvotes: 1
Views: 15762
Reputation: 351
As far as I know from former project, this is the given date format in MySQL and can't be changed so straight forward. I would set the date pattern in mapping the same as in databank (YYYY-MM-DD)
and reformat it later in the usage.
Upvotes: 1