title: Convert string to date to string in Talend Open Studio
body: <p>I am trying to covert a date from one string format (<code>"M/d/yyyy H:mm:ss"</code>) to another (<code>"yyyy-MM-ddTHH:mm:ss"</code>) in Talend Open Studio. I've been reading through forum posts, blogs, and the help documentation, and all of the solutions I've found ultimately result in error. I think it's because most solutions are actually attempting to convert a date to a string or vice versa, but none of them are attempting, as I am, to convert a string to a date and then back again. (And I'm willing to be told that's the wrong way to approach this, but it seems like the natural way to do the conversion since, presumably, Talend knows how to convert all the parts of the Date type.)</p>
  
  <p>My current iteration looks like this:</p>
  
  <pre><code>row2._ACTIVITY_DUE_DATE_==""?"":TalendDate.formatDate("yyyy-MM-dd HH:mm:ss", TalendDate.parseDate("M/d/yyyy H:mm:ss", row2._ACTIVITY_DUE_DATE_)) 
  </code></pre>
  
  <p>So if I feed in <code>5/18/2012 1:00:00 PM</code>, I would want to get back <code>2012-05-18 13:00:00</code>. I'm getting an <code>unparsable date</code> error, which I've included below. I don't understand why this is happening. The expression above should only be trying to parse the date if it's <em>not</em> equal to <code>""</code>, but apparently that's the value it can't parse:</p>
  
  <pre><code>Exception in component tMap_1
  java.lang.RuntimeException: java.text.ParseException: Unparseable date: ""
  at routines.TalendDate.parseDate(TalendDate.java:864)
  at routines.TalendDate.parseDate(TalendDate.java:808)
  at     msm_extras.msm_activities_i360_tasks_0_1.MSM_Activities_i360_Tasks.tFileInputDelimited_1Process(MSM_Activities_i360_Tasks.java:2854)
  at msm_extras.msm_activities_i360_tasks_0_1.MSM_Activities_i360_Tasks.runJobInTOS(MSM_Activities_i360_Tasks.java:3690)
  at msm_extras.msm_activities_i360_tasks_0_1.MSM_Activities_i360_Tasks.main(MSM_Activities_i360_Tasks.java:3549)
  Caused by: java.text.ParseException: Unparseable date: ""
  at java.text.DateFormat.parse(Unknown Source)
  at routines.TalendDate.parseDate(TalendDate.java:850)
  ... 4 more
  </code></pre>