title: Time difference in Groovy
body: <p>I am trying to print start &amp; end time of stage in pipeline along with time taken for completing stage. Not getting expected result.</p>
  <pre><code>script{def start_time = new Date()
  echo &quot;Start Date: ${start_time}&quot;                
  sleep time: 2, unit: 'MINUTES'
  def end_time = new Date()
  def total_time = end_time - start_time
  echo &quot;End Date: ${end_time}&quot;
  echo &quot;Total Time: ${total_time}&quot;}
  </code></pre>