This entity is using LocalDateTime thanks to a AttributeConverter to be able to set the time correctly, for instance it is easier to set UTC and avoid using the deprecated java.util.Date and java.util.Calendar
package com.project.model;
import java.time.LocalDateTime;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity
@Table(name="universal_time")
public class UniversalTime {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long Id;
// @Temporal(TemporalType.TIMESTAMP)
private LocalDateTime date1;
// @Temporal(TemporalType.TIMESTAMP)
private LocalDateTime date2;
// @Temporal(TemporalType.TIMESTAMP)
private LocalDateTime date3;
public Long getId() {
return Id;
}
public void setId(Long id) {
Id = id;
}
public LocalDateTime getDate1() {
return date1;
}
public void setDate1(LocalDateTime date1) {
this.date1 = date1;
}
public LocalDateTime getDate2() {
return date2;
}
public void setDate2(LocalDateTime date2) {
this.date2 = date2;
}
public LocalDateTime getDate3() {
return date3;
}
public void setDate3(LocalDateTime date3) {
this.date3 = date3;
}
}