Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Unparseable Date

807605Aug 1 2007 — edited Aug 1 2007
Hi,

I'm trying to write the current date into a database as a string and then read it back. The part where the date is written is fairly obvious. But I'm writing it here nevertheless.
fund.setDateOfBuying(new Date().toString());
followed by an insert query.

Following is the part where the date is read.
fundRet.setDateOfBuying(DateFormat.getInstance().parse((rs.getString(6).trim())));
And here, I get the following exception.

java.sql.SQLException: Unparseable date: "Wed Jan 10 00:10:00 GMT+05:30 2001"

How do I construct a Date object from the equivalent String ? (since the Date constructor that accepts String as parameter is deprecated)

Thanks!
Neha.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 29 2007
Added on Aug 1 2007
15 comments
2,223 views