title: How to get the runTime of an active task according to its GMT lanuchTime in Spark?
body: <p>I want to get the runtime of an active task. In the REST API page of <code>/applications/[app-id]/stages/[stage-id]</code>, I can get tasks info in detail.</p>
  
  <p><a href="https://i.stack.imgur.com/YeOkI.png" rel="nofollow noreferrer">enter image description here</a></p>
  
  <p>You can see, the <code>executorRunTime</code> is 0 when a task is not completed. I think I can get the runTime according to <code>launchTime</code>. Suppose the <code>launchTime</code> is 2017-12-21T03:15:31.106GMT. I use the following code to compute the runTime.</p>
  
  <pre><code>val format = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss'.'sss'GMT'", Locale.ENGLISH)
  format.setTimeZone(TimeZone.getTimeZone("GMT"))
  val launchTime = format.parse("2017-12-21T03:15:31.106GMT").getTime
  val runTime = Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTimeInMillis - 
                launchTime
  </code></pre>
  
  <p>But I get a negative number. Is the time format wrong? Or what?</p>