Currently, the format of the Date requestDate variable stored looks like: 2017-02-17 00:00:00.0
. I want to convert this into, for example: Friday, February 17, 2017
. I would like to do the conversion here in my entity and return it so that when it's displayed it is more human readable. This will likely happen in the constructor, at this line: this.setRequestDate(doDateConversion(requestDate));
. How can I make this conversion?
My Request entity:
@Entity
@Table(name = "Request")
public class RequestDO implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="request_id")
private Long id;
private Date requestDate;
private String description;
private RequestStatus status;
/*private Boolean read;*/
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="user_id", nullable = false)
private Users users;
public RequestDO() {}
public RequestDO(Users user, Date requestDate) {
this.setUsers(user);
this.setRequestDate(requestDate);
}
@Override
public String toString() {
return String.format(
"RequestDO[id=%d, inital='%s', requestDate='%s']",
getId()
, getUsers().getInitialName()
, getRequestDate());
}
public Date getRequestDate() {
return requestDate;
}
public void setRequestDate(Date requestDate) {
this.requestDate = requestDate;
}
}