title: java.sql.SQLException: ORA-01843: not a valid month
body: <p>I am getting the following error when inserting data into my oracle database.</p>
  
  <pre><code>java.sql.SQLException: ORA-01843: not a valid month
  </code></pre>
  
  <p>In database date is as: dd-MMM-yy (06-MAR-12)<br>
  I am converting 06-03-2012 to dd-MMM-yy by the following method:</p>
  
  <pre><code>String s="06-03-2012";
  
  String finalexampledt = new SimpleDateFormat("dd-MMM-yy").format(new SimpleDateFormat("dd-MM-yyyy").parse(s));
  </code></pre>
  
  <p>So i got 06-Mar-12 which is same as the above database date format still i am getting the error. I am inserting as:</p>
  
  <p>in index.jsp</p>
  
  <pre><code> String todaydate="";
  
  Calendar calendar1 = Calendar.getInstance();
  SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
  todaydate = dateFormat.format(calendar1.getTime());
  
  &lt;input type="text" name="datename" value="&lt;%=todaydate%&gt;"/&gt;
  </code></pre>
  
  <p>in servlet(doPost)</p>
  
  <pre><code>String s=request.getParameter("datename");
  
  PreparedStatement ps=con.prepareStatement("insert into tablename(rest_dt, othercolname) values (to_date(?, 'dd-mm-yyyy'), ?)");
  
  ps.setString(1, s);
  ps.setString(2, otherstringdata);
  
  int  rs=ps.executeUpdate();
  </code></pre>
  
  <p>Any idea please</p>