In my following code snippet:
String horario = evento.getDataOcorrencia().concat(" ").concat(evento.getHoraOcorrencia());
horario = horario.replaceAll("/", "-");
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy hh:mm");
Date parsedDate = dateFormat.parse(horario);
Timestamp timestamp = new Timestamp(parsedDate.getTime());
evento.setHorario(timestamp);
My String
schedule has the following format (example):
28/03/2017 10:00
I need to convert to a timestamp, so far so good, I even change /
by -
. The problem is that when being persisted in the database the value looks like this:
2017-03-21 13:35:00
That is, it is a format that I do not like, I wanted it to be as it is in the example. Does anyone know how I can solve it? The declaration of JPA
looks like this:
@Column
@XmlTransient
private Timestamp horario;