2
Hello, I’m formatting the date with the following code:
Date data = null;
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
data = format.parse(request.getParameter("txtdata"));
} catch (Exception e) {
JOptionPane.showMessageDialog(null,"Erro ao formatar data: " +e.getMessage());
}
event.setEventodata(data);
By clicking register, in the form below:
The following error appears:
I’m saving this in the bank ok? The attribute type is: datetime not null; There’s something wrong with the conversion?
What value
request.getParameter("txtdata")
returns? Tries to use aSystem.out.println
to be sure– Guilherme Nascimento
Format is wrong. Change to
new SimpleDateFormat("dd-MM-yyyy HH:mm:ss")
– user28595
I already changed the format, it didn’t work, because anyway I have to take yyyy-MM-dd, since I’m saving in the "Database".
– Igo
But I just put a Joptionpane.showMessageDialog(null,"-" +data); to return the date and is coming "null", and when giving the error returns the date in the error, I don’t understand it now :s The request.getParameter is correct.
– Igo