• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

date format

 
Ranch Hand
Posts: 87
Hibernate Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have date field in my jsp which i has declared ad date in action in jsp I have declared as
>

and before submitting to database i have formatted it to mm/dd/yyyy and its saved properly. But when i retrieve in list jsp it is displaying along with time.



Could anyone suggest how to display in mm/dd/yyyy

thanks


 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you have configured your database field to store the date as a DATE or TIMESTAMP data type (as opposed to plain text), the database is not going to store the date in the same format you submitted to it. The database is going to store it in whatever format is easiest for it to work with (probably a large integer datatype).
You will probably have to format the java.sql.Date you are retrieving from the database with java.text.SimpleDateFormat to get the output you desire
 
Vallaru smitha
Ranch Hand
Posts: 87
Hibernate Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Joe.

i did the same but

SimpleDateFormat formatter = new SimpleDateFormat("mm/dd/yyyy");
String s = formatter.format(dateValue);
dateValue(formatter.parse(s));

but I am getting an output as
12/12/01 instead of 12/12/2001

is there anyway we could get complete year. I tried all typed formatting.

thanks
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic