I have been configuring Spring auditing for my entity classes. Using annotations, I have something like this:
private Date createdDate
private User createdBy
@Temporal annotation is available since the release of JPA 1.0. @Temporal solves the one of the major issue of converting the date and time values from Java object to compatible database type and retrieving back to the application.
@Column(name = "XDATE")
private Date xDate; //java.util.Date
I hope this will resolve your problem. For more info please refer this link