title: Converting a time String to ISO 8601 format
body: <p>I am trying to create a String in a format like <strong>2015-08-20T08:26:21.000Z</strong><br />
  to <strong>2015-08-20T08:26:21Z</strong></p>
  <p>I know it can be done with some String splitting techniques, but i am wondering if there is an elegant solution for that (with minimal code changes).</p>
  <p>Both of the above are time strings, the final one which i need is Date in ISO 8601 . <a href="https://www.rfc-editor.org/rfc/rfc3339#section-5.6" rel="nofollow noreferrer">https://www.rfc-editor.org/rfc/rfc3339#section-5.6</a></p>
  <p>I have tried a few similar questions like <a href="https://stackoverflow.com/questions/8427169/converting-a-date-string-into-milliseconds-in-java">converting a date string into milliseconds in java</a> but they dont actually solve the purpose.</p>
  <p>Also tried using :</p>
  <pre><code>SimpleDateFormat df = new SimpleDateFormat(&quot;yyyy-MM-dd'T'HH:mmZ&quot;);
  String nowAsString = df.format(new Date());
  </code></pre>
  <p>But it still does not do any String to String conversions. Getting the following error:</p>
  <p><strong>23:04:13,829 WARN  [RuntimeExceptionMapper]  caught RuntimeException: {}: java.lang.IllegalArgumentException: Cannot format given Object as a Date</strong></p>
  <p>Is there some library which someone can suggest ?</p>
  <p>Thanks.</p>