title: How to convert chararray to datetime with milliseconds in pig latin
body: <p>I wish to convert following value which is a chararray in pig</p>
  
  <pre><code>2016-05-11 23:59:57.628197
  </code></pre>
  
  <p>to</p>
  
  <pre><code>2016-05-11T23:59:57.628-05:00
  </code></pre>
  
  <p>How can I do it ?</p>
  
  <p>Following is what I tried considering alias 'a2' contains list of datetime values in chararray in the column named 'input_date_value' </p>
  
  <pre><code>FOREACH a2 GENERATE input_date_value AS input_date:chararray,
                         ToDate(input_date_value,'YYYY-MM-DD HH:mm:ss.SSSSSS') AS modification_datetime:datetime;
  </code></pre>
  
  <p>For input -</p>
  
  <pre><code>2002-07-11 16:58:40.249764
  </code></pre>
  
  <p>Output is -</p>
  
  <pre><code>2002-01-11T16:58:40.249-05:00
  </code></pre>
  
  <p>The month values like '07' are not getting picked up, 
  The created timestamp has month set to 01' i.e. January everytime for all dates.</p>
  
  <p>Can someone help. What am I doing wrong ?</p>