• Post Reply Bookmark Topic Watch Topic
  • New Topic

date format is getting changed  RSS feed

 
Srikanth Adapa
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

I am retrieving data from backend(oracle) by means of jsp form. when I ve queried the date value is in the form '2/3/2009 12:39:58 PM'. but by the time I ve retrieved to the jsp, it is showing in different format. what would be the change to be done to retrieve the date value as it is.

hope some expert would share their views and suggest me.


thanks,
Sri
 
Balagopal Kannampallil
Ranch Hand
Posts: 136
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you use DateFormat utilities.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It look like that you expected that the toString() of java.util.Date returns the date in the same format as it is in Oracle database.

You´re wrong. The toString() of java.util.Date just returns the date (day, month, year, hour, minute, second, timezone) in a fixed pattern which is readable to humans.

Use SimpleDateFormat in Java or use JSTL´s fmt:formatDate in JSP to convert a date to another human readable pattern. How to use it is -as usual- already explained in the Javadoc: http://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat.html
 
Srikanth Adapa
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much.. I ve solved my issue by using SimpleDateFormat class.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!