Hi,
I have a
String in the format of "25/12/2004 19:11:19".
this string needs to be converted to an sql.Date for the purpose of entering into the database through a Callable Statement. Below i am pasting the code,this does not work. I use a util date and then convert it to a sql date .I get an Illegalargument exception..the code is
Calendar calendar =Calendar.getInstance();
calendar.set(Integer.parseInt(cpdt.substring(cpdt.lastIndexOf("/")+1,cpdt.indexOf(":")-2)),Integer.parseInt(cpdt.substring(cpdt.indexOf("/")+1,cpdt.lastIndexOf("/")))-1,Integer.parseInt(cpdt.substring(0,cpdt.indexOf("/"))));
calendar.set(Calendar.HOUR ,Integer.parseInt(cpdt.substring(cpdt.indexOf(":")-2,cpdt.indexOf(":")).trim()));
calendar.set(Calendar.MINUTE,Integer.parseInt(cpdt.substring(cpdt.lastIndexOf(":")-2,cpdt.lastIndexOf(":"))));
calendar.set(Calendar.SECOND,Integer.parseInt(cpdt.substring(cpdt.lastIndexOf(":")+1)));
java.util.Date d = calendar.getTime();
cust_payment_dte =java.sql.Date.valueOf(d.toString());
//this is where the error is thrown
plz help
sharun