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!

Error Unparseable date: "1999-05-03"

807607Nov 14 2006 — edited Nov 14 2006
Hi All,
I am getting an unparseable date error. The database returns date of format "1999-05-03". I would like to format the date to yyyyMMdd format. My code is as follows
Date effectiveDt = new Date();
String dateFormat = "yyyyMMdd";
DateFormat format = new SimpleDateFormat(dateFormat);
		format.setLenient(false);
effectiveDt = (Date)format.parse(rs.getDate("ear_date_fr").toString());
I tried another way by converting the date returned by the databse to SQL date and it still gives problem...
effectiveDt = (Date)format.parse(formUtil.returnSqlDate(rs.getDate("ear_date_fr").toString()).toString());
formUtil.returnSqlDate code is actually as follows:
public static java.sql.Date returnSqlDate(String formDate) {
	java.util.Date utilDt = null;

	SimpleDateFormat df1 = new SimpleDateFormat("yyyyMMdd");

	try {
		utilDt = df1.parse(formDate);
	} 
	catch (ParseException pxp) {
		return null;
	}

	return new java.sql.Date(utilDt.getDate());
}
any help appreciated..

hepzi leon soon
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 12 2006
Added on Nov 14 2006
11 comments
994 views