This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SimpleDateFormat Help

 
Pranit Saha
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi pals,
I'm having SQL server as Backend.. so i get the dates like "2001-12-20 10:12:11.665" i want to format this date using SimpleDateFormat Class.. The thing is- does format() method of this class take a String argument.. i mean as i know it takes a Date object.. but in my case how can i format the retrieved date
like dd-MMM-yyyy.. pls help..
Pranit..
 
Kapil Keskar
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you can use SimpleDateFormat class to filter ther required things what you want.
you have to specify date format in Simpl... class. & then that object is used
like object of Simpl... is sdf then sdf.format(dt) can be used.
But we have to use in Statement type, we cannot use PreparedStatement there.
you can contact me at kapilkeskar@hotmail.com
hope you got the answer
 
Pranit Saha
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kapil,
The same thing i did.. but the thing is, i am retrieving the date from the database as rs.getString("postdate").. and it is stored in a String variable.. so can i pass String variable in sdf.format().. if i can't the how can i do so.. pls reply..
Pranit..
 
Pat Wallwork
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pranit,
Try this:

formattedDate should now hold the date the way you wish to display it.
Pat
 
Pranit Saha
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Pat,
It worked fine.. and my problem is totally solved..
can u pls tell me one more thing.. that is:
I m sending data from a textarea to a database table.. the prob is, when i retrieve the data from the database it doesn't come in that format as i typed.. what can i do for this..
Thanks again,
Pranit..
Originally posted by Pat Wallwork:
[B]Pranit,
Try this:

formattedDate should now hold the date the way you wish to display it.
Pat[/B]

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic