title: How to convert a string to timestamp with milliseconds in Hive
body: <p>I have a string '20141014123456789' which represents a timestamp with milliseconds that I need to convert to a timestamp in Hive (0.13.0) without losing the milliseconds.</p>
  
  <p>I tried this but unix_timestamp returns an integer, so I lose the milliseconds:</p>
  
  <pre><code>from_unixtime(unix_timestamp('20141014123456789', 'yyyyMMddHHmmssSSS'))      &gt;&gt; 2014-10-14 12:34:56    
  </code></pre>
  
  <p>Casting a string works:</p>
  
  <pre><code>cast('2014-10-14 12:34:56.789' as timestamp)      &gt;&gt; 2014-10-14 12:34:56.789
  </code></pre>
  
  <p>but my string isn't in that form.</p>
  
  <p>I think I need to reformat my string from '20141014123456789' to '2014-10-14 12:34:56.789'. My challenge is how to do that without a messy concatenation of substrings. </p>