File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes SimpleDateFormat Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "SimpleDateFormat Help" Watch "SimpleDateFormat Help" New topic
Author

SimpleDateFormat Help

Pranit Saha
Ranch Hand

Joined: Sep 09, 2001
Posts: 130
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

Joined: Dec 04, 2001
Posts: 47
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

Joined: Sep 09, 2001
Posts: 130
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

Joined: Sep 23, 2001
Posts: 72
Pranit,
Try this:

formattedDate should now hold the date the way you wish to display it.
Pat
Pranit Saha
Ranch Hand

Joined: Sep 09, 2001
Posts: 130
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]

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SimpleDateFormat Help