Avatar of saleemkhan
saleemkhan

asked on 

Error Cannot convert form string to date?

hi all,
              I am getting error   Error Cannot convert form string to date?
           at   Date orderSent_dt=df.format(customerlist.getOrder_dt());



Here is my code

----------Java Code ---------------------

public class CustomerList {

String order_dt="";


public Vector getCustomerList() {
Vector vRow = new Vector();
Vector customers=new Vector();

String sql="select *  from mytable";
System.out.println("sql="+sql);            
vRow = SQLManager.select(sql);
String element;
for (Iterator iter = vRow.iterator(); iter.hasNext();) {
      customerList = new CustomerList();
      element = (String)iter.next();
      customerList.setOrder_dt((element == null ? "" : element));      
              .//remaing code goes below            
      .
                     .
                   
customers.add(customerList);  
}
}


public void setOrder_dt(String string) {
      order_dt = string;
      
}
public String getOrder_dt() {
return order_dt;
      }

}      



JSP code

SimpleDateFormat df = new SimpleDateFormat("DD-MMM-YYYY");
CustomerList customerlist = null;
Vector customers=new Vector();


customerlist=new CustomerList();  //Creating the instance of the class



<%for (Iterator iter = customers.iterator(); iter.hasNext();) {
        customerlist=(CustomerList) iter.next();
         if (customerlist !=null)
            {
              indx++;
               Date orderSent_dt=df.format(customerlist.getOrder_dt());
             %>
                <tr>
                    <td width='5%'  nowrap align='center' bgcolor="<%=tdDataColor%>"><font face='Arial'><%=(customerlist.getOrder_dt() == null? "":customerlist.getOrder_dt())%>&nbsp;</font></td>  
              </tr>
               
             <%
            }
        }%>


JSP

Avatar of undefined
Last Comment
mrcoffee365

8/22/2022 - Mon