I have english date coming in string format such as 2011-12-12
.
I need to convert it into Date format so I tried :
String assignDates="2011-12-12";
DateFormat df = new SimpleDateFormat("YYYY-MM-dd");
Date dates = df.parse(assignDates);
cstmt.setDate(2,dates);
But i need to set it into cstmt.setDate(2,dates); but it is showing me error in this line like this:
The method setDate(int, java.sql.Date) in the type PreparedStatement is not applicable for the arguments (int, java.util.Date)
The full code is:
public String getConvertedDateToBs(String assignDates) {
try
{
DateFormat df = new SimpleDateFormat("YYYY-MM-dd");
System.out.println("yo ni chiryo"+assignDates);
conn = DriverManager.getConnection(dbProperties.getDatabaseUrl());
System.out.println("chiryoassignDatea");
CallableStatement cstmt = conn.prepareCall("{? = call PCFN_LIB_ETON(?)}");
cstmt.registerOutParameter(1,Types.VARCHAR);
//java.sql.Types.VARBINARY
Date dates = df.parse(assignDates);
cstmt.setDate(2,dates);
cstmt.executeUpdate();
dateInBs = cstmt.getString(1);
/*dateInBs = df.format(assignBsDate);*/
System.out.println(dateInBs);
}
catch (SQLException e)
{
System.err.println(e.getMessage());
}
return dateInAd;
}