title: Convert string timestamp "yyyy-mm-dd'T'HH:mm:ss.SSS+ZZ:ZZ" to string timestamp "yyyy-mm-dd'T'HH:mm:ss.SSSZ"
body: <p>For example, if I have the string timestamp <code>2022-01-12T19:41:27.000+00:00</code>, I would like to get <code>2022-01-12T19:41:27.000Z</code>.</p>
  <p>I would like to ensure that I come with a solution that can in the future take string timestamps with the format &quot;yyyy-mm-dd'T'HH:mm:ss.SSS+ZZ:ZZ&quot; OR any other input format but will always return one standard output which is &quot;yyyy-mm-dd'T'HH:mm:ss.SSSZ&quot;.</p>
  <p>So far, I have come up with:</p>
  <pre><code>String ts = &quot;2022-01-12T19:41:27.000+00:00&quot;;
  Date date = new SimpleDateFormat(&quot;yyyy-mm-dd'T'HH:mm:ss.SSS+ZZ:ZZ&quot;, 
  Locale.US).parse(ts);
  System.out.println(date);
  
  Timestamp tsp = new Timestamp(date.getTime()); 
  SimpleDateFormat formatter = new SimpleDateFormat(&quot;yyyy-mm-dd'T'HH:mm:ss.SSSZ&quot;);
  String str = formatter.format(tsp);
  System.out.println(str);
  </code></pre>
  <p>But I run into the following exception:</p>
  <pre><code>error: unreported exception ParseException; must be caught or declared to be thrown
  Date date = new SimpleDateFormat(&quot;yyyy-mm-dd'T'HH:mm:ss.SSS+ZZ:ZZ&quot;, Locale.US).parse(ts);
  </code></pre>