This discussion is archived
12 Replies Latest reply: May 21, 2008 10:38 PM by 807591 RSS

cast a Strring to to Date data type ??

807591 Newbie
Currently Being Moderated
Hi,
I want to cast the date which is in string data type in to Date data type . Below is the code which I wrote.
SimpleDateFormat formater=new SimpleDateFormat("dd/MM/yyyy");
 String sDate=request.getParameter("date"); // retrive the date from jsp .
 Date date=(Date)formater.parse(sDate);
String SQL_QUERY="from QuesClass where createdDate ='"+date+"'"; // the query.
when I run the code it throws an NullPointerException. Can any one help me.
Thanks in advance.