title: Creating a timestamp in a Jenkinsfile
body: <p>I'm struggling a little creating a timestamp in a format that I want using a scripted pipeline in Jenkins. Here's my code from the pipeline:</p>
  
  <pre><code>def cal = Calendar.instance
  def dateFormat = 'YYYYMMDD-hhmmss'
  def timeZone = TimeZone.getTimeZone('CST')
  def timeStamp = cal.time​.format(dateFormat,timeZone)​
  println "Timestamp is: ${timeStamp}"
  env.BUILD_TIMESTAMP = timeStamp
  </code></pre>
  
  <p>When I run via Jenkins, I get the following:</p>
  
  <pre><code>org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: unclassified field java.util.GregorianCalendar time​
      at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.unclassifiedField(SandboxInterceptor.java:387)
      at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:371)
  </code></pre>
  
  <p>I've seen mention of similar issues with different fields online, but the workaround of adding it to <code>scriptapproval.xml</code> (and restarting Jenkins) doesn't seem to be working.</p>
  
  <p>Anyone have a method of generating a timestamp in a format similar to what I'm trying to do?</p>