title: How can I convert a java.util.Date object to the restricted form of the canonical representation of dateTime
body: <p>I need to convert a java.util.Date variable to a representation similar to the one below. </p>
  
  <pre><code> 1995-12-31T23:59:59.999Z
  </code></pre>
  
  <p>The format for this date field is of the form 1995-12-31T23:59:59Z, and  is a more restricted form of the canonical representation of dateTime <a href="http://www.w3.org/TR/xmlschema-2/#dateTime" rel="nofollow noreferrer">http://www.w3.org/TR/xmlschema-2/#dateTime</a>.    </p>
  
  <p>The trailing "Z" designates UTC time and is mandatory.</p>