0
I’ve been doing the exercise "6.4 Optional exercises: List of contacts with scriptlet" of Caelum and there is a question that says so : "2) Note that the date appeared in a complicated way to read. Try to show it formatted using the class Simpledateformat"
I need to put this part:
String dataFormatada = new SimpleDateFormat("dd/MM/yyyy").format(contato.getDataNascimento())
But I don’t know where to put it <%=contact getDataNascimen.... , I tried outside the table and nothing..
This is my code!
<table>
<tr>
<th>Nome</th>
<th>E-mail</th>
<th>Endereço</th>
<th>Data de Nascimento</th>
</tr>
<%
ContatoDao dao = new ContatoDao();
List<Contato> contatos = dao.getLista();
for (Contato contato : contatos){
%>
<tr>
<td><%=contato.getNome() %></td>
<td><%=contato.getEmail() %></td>
<td><%=contato.getEndereco() %></td>
<td><%=contato.getDataNascimento().getTime() %></td>
</tr>
<%
}
%>
</table>
Take a look at this post https://answall.com/questions/72828/formata%C3%A7%C3%A3o-de-datas-com-Calendar-dd-mm-yyyy
– Marcelo T. Cortes
Have you tried that:
<%=new SimpleDateFormat("dd/MM/yyyy").format(contato.getDataNascimento())%>
?– igventurelli