title: java-How should one pass a date value to MySQL?
body: <p>I have a column field called <code>StartDate</code> in MySQL of <code>Date</code> datatype. In my application, I defined a way to show the current date onn my page like this.</p>
  
  <pre><code>String today = CoreUtil.parseDate(new Date());
  </code></pre>
  
  <p>This basically returns the date in <code>YYYY-MM-DD</code> format and stored it in a string which is fine.</p>
  
  <p>Now, I would like to pass this value into a function that inserts the value to the column <code>StartDate</code>.</p>
  
  <p>The function I declared is as follow:</p>
  
  <pre><code>public void insert_update(String nodeid,String ts,Date startdt,Date enddt,int enable)
  </code></pre>
  
  <p>I am calling this function and passing the value <code>today</code> to it like below:</p>
  
  <pre><code> fileFacade.insert_update(...,....,today,....,...);
  </code></pre>
  
  <p>Now I am not an expert in this date thingy and seeing it wouldn't allow me to pass the value as I defined it as Date parameter, how should I handle this issue?</p>
  
  <p>Should I convert it back to Date format and pass the value or does MySQL allow insertion of string value into a Date datatype column?</p>
  
  <p>I just want to store the value in my table in <code>YYYY-MM-DD</code> format.</p>
  
  <p>edit:</p>
  
  <p>My function:</p>
  
  <pre><code>public void insert_update(String nodeid,String ts,Date startdt,Date enddt,int enable){
       try {
  
           //   UrlLink attr = em.find(UrlLink.class,n);
  
  
           String sql="UPDATE urllink SET STARTDT="+startdt+",ENDDT="+enddt+",ENABLE="+enable+"WHERE URL='f0="+nodeid+"&amp;ts="+ts + "'";
  
           em.createNativeQuery(sql).executeUpdate();
  
  
  
  
       }catch (Exception e) {
           e.printStackTrace();
       }
  
   }
  </code></pre>