title: Java datetime format convert
body: <p>date here my problem:</p>
  
  <pre><code>String datetime = "2012-03-24 23:20:51";
  </code></pre>
  
  <p>I know that that string is in UTC timezone.
  I need to convert this string to format "yyy-mm-dd'T'HH:mm:ssZ".</p>
  
  <p>To do this I'm using following code:</p>
  
  <pre><code>    SimpleDateFormat inFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      inFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
      Date inDate = inFormatter.parse(datetime);
      SimpleDateFormat outFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
      outFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
      String output = outFormatter.format(inDate);
  </code></pre>
  
  <p>The problem is that this code is running on a server with timezone UTC+1 and the result it gave me is this:</p>
  
  <pre><code>output = "2012-03-24T21:20:51+0000"
  </code></pre>
  
  <p>It removes 2 hours from the initial time and puts the UTC timestamp (0000).</p>
  
  <p>Can you please help me solving this?
  Thank you.</p>