title: Convert unix timestamp between different timezones and different DST in Java
body: <p><strong>PROBLEM SOLVED</strong> External device was computing and sending non-standard 2 hours shifted timestamp, which hugely confused me and started this thread. <strong>TIMESTAMP BY ITSELF IS NOT AFFECTED BY TIMEZONES</strong> , timezones apply only when converting in/from human readable forms.</p>
  
  <hr>
  
  <p>I have timestamp (seconds from unix epoch) in UTC timezone - no DST (daylight saving time).</p>
  
  <p>I want timestamp (seconds from unix epoch) in "Europe/Prague" timezone, that uses DST.</p>
  
  <p>I used to think that unix timestamp is unbound by timezones, that timezones affect only process of converting timestamp to human readable formats. But it doesn't look like that. And the more I am trying to convert it (using Calendar and TimeZone classes), the more confused and lost I am getting.</p>
  
  <p>this code DOES NOT work as expected:</p>
  
  <pre><code>Calendar cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("UTC"));
  cal.setTimeInMillis(ts*1000);
  cal.setTimeZone(TimeZone.getTimeZone("Europe/Prague"));
  return cal.getTimeInMillis()/1000;
  </code></pre>