title: how to insert Timestamp in database?
body: <p>I am getting this error: </p>
  
  <blockquote>
    <p>java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd 
    hh:mm:ss[.fffffffff]  </p>
  </blockquote>
  
  <p>Here is my java code:</p>
  
  <pre><code>&lt;%  int reg;
  
          String sdate = request.getParameter("sdate");
          //Timestamp ts=request.get
        //out.println(sdate);
           String text = "0000-00-00 00:00:00";
         Timestamp ts = Timestamp.valueOf(text);
         // Timestamp ts1=Timestamp.valueOf(sdate);
         //  Timestamp ts2=Timestamp.valueOf(edate);
      try{
            String s;
        Format formatter;
       Date date = new Date(sdate);
       //out.println(date);
        formatter = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
       s = formatter.format(date);
       out.println(s);
          PreparedStatement ps=cn.prepareStatement("insert into c1 values(?)");
                             // ps.setString(1,ts);
           ps.setTimestamp(1,ts);
  
  
  
                              int i=ps.executeUpdate();
                              if(i==1)
                          {
                         pw.println("record inserted");
                          }
                          else
                          {
                          pw.println("not iNSERTED");
                          }
                          //cn.close();
  
                         }
                   catch(Exception e)
                          {
                              out.println(e.toString());
                          }
  
      %&gt;
  </code></pre>
  
  <p>Any Suggestions? </p>