• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date format

 
Fernando Dominguez
Ranch Hand
Posts: 104
Debian Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have this sql date 2009-05-11 00:00:00.0 in to my data base

String fecha = rs.getString("fecha")); // fecha is now 2009-05-11

java.text.SimpleDateFormat df= new SimpleDateFormat("dd-MM-yyyy");
java.util.Date d = df.parse(rs.getString("fecha"));
System.out.println(d); //shows Thu Oct 29 00:00:00 CET 16
It doesn't retieve the year , I also trying to convert with <fmt:formatDate value='${documento.dateFecha}' type="date" pattern="dd-MM-yyyy"/>
and i get 29-10-0016
I wnayt to get day- moth-year;
why i lost the year?

thanks
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Fernando Dominguez:

String fecha = rs.getString("fecha")); // fecha is now 2009-05-11

java.text.SimpleDateFormat df= new SimpleDateFormat("dd-MM-yyyy");


Look at the format of your string. Look at the pattern you are passing to SimpleDateFormat. It's not really surprising you are not getting the data you want.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like "2009-05-11" will parse better with "yyyy-MM-dd". Let us know if that helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic