title: Convert string to appropriate date with timezone java
body: <p>I am Having Date with it's timezone, I want to convert it to another Timezone, E.g. I have Date '3/15/2013 3:01:53 PM' which is in TimeZone 'GMT-06:00'. I want to convert this in 'GMT-05:00' timezone. I have search lot, and I am confuse about How actually Date is working. How to Apply timezone to date. I have try with SimpleDateFormat, Calender and also with offset.</p>
  
  <pre><code>DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss aaa XXX");
  df.setTimeZone(TimeZone.getTimeZone("GMT")); 
  Date dt = null;
  try {
      dt = df.parse("3/15/2013 3:01:53 PM -06:00");
  } catch (ParseException e) {
      e.printStackTrace();
  } 
  String newDateString = df.format(dt);
  System.out.println(newDateString);
  </code></pre>
  
  <p>It returns output 
  <code>03/15/2013 09:01:53 AM Z</code>.
  I guess it should be 
  <code>03/15/2013 09:01:53 PM Z</code>, because time in 'GMT-06:00' timezone, so it should be HH+6 to get time in GMT. I want Date in "yyyy-MM-dd HH:mm:ss" format where HH is in 24 hour.Please Help me with example. Thanks in advance. </p>
  
  <p>EDIT :</p>
  
  <p>I am converting the string into date using SimpleDateFormat</p>
  
  <pre><code>DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss aaa");
      Date dt = null;
      try {
          dt = df.parse("3/15/2013 3:01:53 PM");
      } catch (ParseException e) {
          e.printStackTrace();
      }
  </code></pre>
  
  <p>Now, as you say, I specify to Calendar that my date is in 'GMT-06:00' timezone and set my date,</p>
  
  <pre><code>Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT-6"));
  cal.setTime(dt);
  </code></pre>
  
  <p>Now, I am telling calendar that I want date in 'GMT'</p>
  
  <pre><code>cal.setTimeZone (TimeZone.getTimeZone("GMT"));
  </code></pre>
  
  <p>System.out.println(cal.getTime());</p>
  
  <p>OutPut: </p>
  
  <pre><code>Fri Mar 15 03:01:53 CDT 2013
  </code></pre>
  
  <p>Please know me if i am going wrong.</p>