Hello guys, I am developing a crud with Javaweb, I tried to create a new employer(Funcionario) with it’s date of birth, but i had problems with date conversion. Look the codes below:
my input: <input type="date" value="${funcionario.dataNascimento}" name="datanascimentofuncionario" id="datanascimentofuncionario"/>
Dao:
stmt.setDate(1, new java.sql.Date(funcionario.getDataNascimento().getTime()));
Servlet:
else if (dados.equals("datanascimentofuncionario")) {
funcionario.setDataNascimento(Conversoes.converterData(fileItem.getString()));
The class to convert:
public class Conversoes {
public static Date converterData(String data) throws ParseException {
if (!data.trim().equals("") || !data.equals("")) {
SimpleDateFormat fmt = new SimpleDateFormat("dd/MM/yyyy");
Date date = fmt.parse(data);
return date;
} else {
return null;
}
}
}
does anybody knows what can be the problem?
I appreciate your help guys
#stayathome