title: How to convert UTC formatted string to calendar in specific timezone?
body: <p>I'm trying to convert some string that is in UTC time to a java Calendar object that should be set to GMT-5.</p>
  
  <p>My current UTC string input is this:</p>
  
  <blockquote>
    <p>UTC date : 20050329174411</p>
  </blockquote>
  
  <p>I use this code (I detect the 'pattern' as shown below):</p>
  
  <pre><code>DateFormat dateFormat = new SimpleDateFormat(pattern);
  Date date = dateFormat.parse(utcDate);
  calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT-5"));
  calendar.setTime(date);
  </code></pre>
  
  <p>I then printed the time like this:</p>
  
  <blockquote>
    <p>calendar.getTime()</p>
  </blockquote>
  
  <p>And I got this result:</p>
  
  <blockquote>
    <p>GMT date : Tue Mar 29 17:44:11 EST 2005</p>
  </blockquote>
  
  <p>I need to support theses date/time string patterns:</p>
  
  <pre><code>FORMAT_UTC4 = "yyyy";           
  FORMAT_UTC6 = "yyyyMM";         
  FORMAT_UTC8 = "yyyyMMdd";       
  FORMAT_UTC10 = "yyyyMMddHH";    
  FORMAT_UTC12 = "yyyyMMddHHmm";  
  FORMAT_UTC14 = "yyyyMMddHHmmss";
  </code></pre>
  
  <p>I would be expecting the time to be set to "12:44:11". I have read a couple of examples and I find date time handling pretty confusing. For me, it's always the same, I get some sort of string formatted UTC and I convert it to GMT-5. I really feel it should be easy!</p>
  
  <p>Ref 1 : <a href="https://stackoverflow.com/questions/308683/how-can-i-get-the-current-date-and-time-in-utc-or-gmt-in-java">How can I get the current date and time in UTC or GMT in Java?</a></p>
  
  <p>Ref 2 : <a href="https://stackoverflow.com/questions/230126/how-to-handle-calendar-timezones-using-java">How to handle calendar TimeZones using Java?</a></p>