title: Convert date String "Thu Oct 15 05:19:21 XXX 2015" to "yyyy-MM-dd" with JAVA
body: <p>I am new to java and I'm trying to make a format conversion dates</p>
  
  <p>I want convetir a date, "Thu Oct. 15 2015 5:19:21 XXX 2015" string type ... this format "yyyy-MM-dd"</p>
  
  <p>Try "SimpleDateFormat" but not worked.
  resulting in "Unparseable date"</p>
  
  <pre><code>      Input:
            String = "Thu Oct 15 05:19:21 XXX 2015"
  
        Output:
            String="2015-10-15"
  </code></pre>
  
  <p>sorry for my English...</p>
  
  <p>This is My code :</p>
  
  <pre><code>public static String formatDate(String string) {
      DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
      Date date;
      try {
          date = format.parse(string);
          getDateFormated(date, false);
          return getDateFormated(date, false);
      } catch (ParseException ex) {
  
      }
      return "";
  } 
  
  public static String getDateFormated(Date date,boolean withFormatHour) {
      if (date != null) {
          String format = "yyyy-MM-dd";
          if (withFormatHour) {
              format = "yyyy-MM-dd HH:mm:ss";
          }
          return new SimpleDateFormat(format).format(date);
      }
      return "";
  } 
  </code></pre>
  
  <p>Thank you so much!!!</p>