when i am using the code to convert string to sql.Date
DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
Date d = df.parse(leavefrom);
String dfrom=df.format(d);
java.sql.Date dd = new java.sql.Date(d.getTime());
Date dt = df.parse(until);
String dto=df.format(dt);
java.sql.Date ddt = new java.sql.Date(dt.getTime());
I am facing the error given below because of the array so how should i code to convert it into sql.Date when the string[] is to be converted to sql.Date.Pls suggest me.
Thanks in advance.
Error: 500
Internal Servlet Error:
org.apache.jasper.JasperException: Unable to compile class for JSPC:\j2sdkee1.2.1\repository\shiju-f70efc8fa\web\_0005cupdate_0002ejspupdate_jsp_11.java:184: Incompatible type for method. Can't convert java.lang.String[] to java.lang.String.
Date d = df.parse(leavefrom);
^
C:\j2sdkee1.2.1\repository\shiju-f70efc8fa\web\_0005cupdate_0002ejspupdate_jsp_11.java:189: Incompatible type for method. Can't convert java.lang.String[] to java.lang.String.
Date dt = df.parse(until);
^
C:\j2sdkee1.2.1\repository\shiju-f70efc8fa\web\_0005cupdate_0002ejspupdate_jsp_11.java:201: [] can only be applied to arrays. It can't be applied to java.sql.Date.
ps.setDate(1,dd[counter]);
^
C:\j2sdkee1.2.1\repository\shiju-f70efc8fa\web\_0005cupdate_0002ejspupdate_jsp_11.java:202: [] can only be applied to arrays. It can't be applied to java.sql.Date.
ps.setDate(2,ddt[counter]);
^
4 errors
These errors help to understand the problem -
For 1st Error - use Date d = df.parse(leavefrom[counter]);
For 2nd error - use Date dt = df.parse(until[counter]);
and then in last 2 errors why are you using ps.setDate(1,dd[counter])
instead it should be ps.setDate(1,dd);