title: Convert Date/Time for given Timezone - java
body: <p>I want to convert this GMT time stamp to GMT+13:</p>
  <pre><code>2011-10-06 03:35:05
  </code></pre>
  <p>I have tried about 100 different combinations of DateFormat, TimeZone, Date, GregorianCalendar etc. to try to do this VERY basic task.</p>
  <p>This code does what I want for the CURRENT TIME:</p>
  <pre><code>Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone(&quot;GMT&quot;));
  
  DateFormat formatter = new SimpleDateFormat(&quot;dd MMM yyyy HH:mm:ss z&quot;);    
  formatter.setTimeZone(TimeZone.getTimeZone(&quot;GMT+13&quot;));  
  
  String newZealandTime = formatter.format(calendar.getTime());
  </code></pre>
  <p>But what I want is to set the time rather than using the current time.</p>
  <p>I found that anytime I try to set the time like this:</p>
  <pre><code>calendar.setTime(new Date(1317816735000L));
  </code></pre>
  <p>the local machine's TimeZone is used. Why is that? I know that when &quot;new Date()&quot; returns UTC+0 time so why when you set the Time in milliseconds does it no longer assume the time is in UTC?</p>
  <p>Is it possible to:</p>
  <ol>
  <li>Set the time on an object (Calendar/Date/TimeStamp)</li>
  <li>(Possibly) Set the TimeZone of the initial time stamp (calendar.setTimeZone(...))</li>
  <li>Format the time stamp with a new TimeZone (formatter.setTimeZone(...)))</li>
  <li>Return a string with new time zone time. (formatter.format(calendar.getTime()))</li>
  </ol>