title: spark scala long converts to timestamp with milliseconds in parquet dataframe
body: <p>Could someone please guide me that how to convert long to timestamp with milliseconds?
  I know how to do to the <code>yyyy-MM-dd HH:mm:ss</code>
  But I would like to the milliseconds <code>yyyy-MM-dd HH:mm:ss.SSS</code></p>
  <p>My parquet structure is like this</p>
  <pre><code>|-- header: struct (nullable = true)
   |    |-- time: long (nullable = true)
  ...
  </code></pre>
  <p>One sample for time is 1600676073054:</p>
  <p><strong>Scala</strong></p>
  <pre><code>scala&gt; spark.sql(&quot;select from_unixtime(word) as ts, word from tmp_1&quot;).show(false)
  +--------------------+-------------+
  |ts                  |word         |
  +--------------------+-------------+
  |52693-05-28 18:30:54|1600676073054|
  +--------------------+-------------+
  
  
  scala&gt; spark.sql(&quot;select from_unixtime(word/1000) as ts, word from tmp_1&quot;).show(false)
  +-------------------+-------------+
  |ts                 |word         |
  +-------------------+-------------+
  |2020-09-21 16:14:33|1600676073054|
  +-------------------+-------------+
  
  
  scala&gt; spark.sql(&quot;select from_unixtime(word) as ts, word from tmp_1&quot;).show(false)
  +--------------------+-------------+
  |ts                  |word         |
  +--------------------+-------------+
  |52693-05-28 18:30:54|1600676073054|
  +--------------------+-------------+
  
  </code></pre>
  <p><strong>Sql Server</strong></p>
  <pre><code>declare @StartDate datetime2(3) = '1970-01-01 00:00:00.000'
  , @milliseconds bigint = 1600676073054
  , @MillisecondsPerDay int = 60 * 60 * 24 * 1000 -- = 86400000
  
  SELECT  DATEADD(MILLISECOND, TRY_CAST(@milliseconds % @millisecondsPerDay AS INT), DATEADD(DAY, TRY_CAST(@milliseconds / @millisecondsPerDay AS INT), @StartDate));
  --2020-09-21 08:14:33.054
  </code></pre>
  <p>I would like to know how to convert out the 054 as milliseconds.</p>
  <p>Thanks.</p>