title: Converting time to "HH:mm:ss" using Calendar and SimpleDateFormat adds 1 hour
body: <h2>Request</h2>
  
  <p>I need to convert time saved in seconds -> to "HH:mm:ss" (and other formats in the future).</p>
  
  <p>E.g. <strong><code>9</code> seconds -> <code>"00:00:09"</code>.</strong></p>
  
  <p>However, the <code>Calendar</code> class always <strong>adds +1 hour</strong>. I assume it is because of my timezone (which is <code>"Europe/Prague"</code>) or daylight savings time.</p>
  
  <h2>Testing</h2>
  
  <p>First simple usage of <code>Date</code> class. Then three times of <code>Calendar</code> with different timezones, trying methods <code>setTimeInMillis()</code> and <code>set()</code>.</p>
  
  <pre><code>// Declarations
  Calendar cal;
  SimpleDateFormat simpleDateFormat = new SimpleDateFormat( format );
  String result;
  </code></pre>
  
  <p>Date class usage:</p>
  
  <pre><code>// Simple Date class usage
  Date date = new Date( timeInSecs * 1000 );
  result = simpleDateFormat.format( date );             // WRONG result: "01:00:09"
  </code></pre>
  
  <p>Calendar class with "GMT":</p>
  
  <pre><code>// Calendar - Timezone GMT
  cal = new GregorianCalendar( TimeZone.getTimeZone( "GMT" ) );
  
  cal.setTimeInMillis( timeInSecs * 1000 );
  result = simpleDateFormat.format( cal.getTime() );    // WRONG result: "01:00:09"
  
  cal.set( 1970, Calendar.JANUARY, 1, 0, 0, timeInSecs );
  result = simpleDateFormat.format( cal.getTime() );    // WRONG result: "01:00:09"
  </code></pre>
  
  <p>Calendar class with "UTC":</p>
  
  <pre><code>// Calendar - Timezone UTC
  cal = new GregorianCalendar( TimeZone.getTimeZone( "UTC" ) );
  
  cal.setTimeInMillis( timeInSecs * 1000 );
  result = simpleDateFormat.format( cal.getTime() );    // WRONG result: "01:00:09"
  
  cal.set( 1970, Calendar.JANUARY, 1, 0, 0, timeInSecs );
  result = simpleDateFormat.format( cal.getTime() );    // WRONG result: "01:00:09"
  </code></pre>
  
  <p>Calendar class with "default" - "Europe/Prague":</p>
  
  <pre><code>// Calendar - Timezone "default" (it sets "Europe/Prague")
  cal = new GregorianCalendar( TimeZone.getDefault() );
  
  cal.setTimeInMillis( timeInSecs * 1000 );
  result = simpleDateFormat.format( cal.getTime() );    // WRONG result: "01:00:09"
  
  cal.set( 1970, Calendar.JANUARY, 1, 0, 0, timeInSecs );
  result = simpleDateFormat.format( cal.getTime() );    // CORRECT result: "00:00:09"
  </code></pre>
  
  <p><strong>In the last case I got the right result but I do not understand why.</strong></p>
  
  <h2>Questions</h2>
  
  <ol>
  <li><strong>Why the last case works?</strong> (And the one before doesn't?)</li>
  <li>How should I use the Calendar class to be able to simply pass time in seconds to it (without any parsing)?</li>
  <li>Is there another solution (another class)? Except for parsing it on my own.</li>
  </ol>