title: java.lang.IllegalArgumentException: Cannot format given Object as a Date
body: <p>I  recive a date in this format </p>
  
  <pre><code>2014-12-09 02:18:38
  </code></pre>
  
  <p>which i need to convert it to </p>
  
  <pre><code>09-12-2014 02:18:38
  </code></pre>
  
  <p>I tried converting this way </p>
  
  <pre><code>import java.text.ParseException;
  import java.text.SimpleDateFormat;
  public class TestDate {
      public static void main(String[] args) throws ParseException {
          SimpleDateFormat sdf = new SimpleDateFormat("dd-mm-YYYY HH:mm:ss");
          String input = "2014-12-09 02:18:38";
          String strDate = sdf.format(input);
          System.out.println(strDate);
      }
  }
  </code></pre>
  
  <p>But i am getting this exception during Runtime</p>
  
  <pre><code>Exception in thread "main" java.lang.IllegalArgumentException: Cannot format given Object as a Date
      at java.text.DateFormat.format(DateFormat.java:301)
      at java.text.Format.format(Format.java:157)
      at TestDate.main(TestDate.java:15)
  </code></pre>
  
  <p>Could anybody please help me how to resolve this . </p>