File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes convert String to Date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "convert String to Date" Watch "convert String to Date" New topic
Author

convert String to Date

meena latha
Ranch Hand

Joined: Jan 24, 2005
Posts: 219
Hi.

I have written a small program that calculate 30 day
old Date from current date.I want a the date to be formatted in MM/dd/yyyy format.Below code is giving ClassCastException at line 1.Not sure wat is wrong.Please correct me.


Thanks

[ March 16, 2006: Message edited by: meena latha ]
[ March 16, 2006: Message edited by: meena latha ]
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Note that java.sql.Date extends java.util.Date.

In this example, the true type is java.util.Date (as returned by SimpleDateFormat's parse method), but you're trying to downcast to java.sql.Date.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: convert String to Date
 
Similar Threads
String conversion
dates and JDBC
string to timestamp
Code review required for converting dateformat
Convert Calendar to String