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