title: Android time zone and DST issue
body: <p>I have an application which uses a schedule. The user picks what time the schedule should start/end, and I display that start/end time back to the user. Problem is, the time that is displayed back is off, since the DST change.</p>
  
  <p>I can fix the issue for my time zone (Eastern time) or I can fix the issue for GMT, and if I setup a specific case for GMT, Alaskan time is still wrong. Any suggestions?</p>
  
  <p>here's my code:</p>
  
  <p>the time that is being displayed:</p>
  
  <pre><code>long startTimeMillis = (startHour * 1000 * 60 * 60) + (startMin * 1000 * 60) - getTimeOffset();
  </code></pre>
  
  <p>getTimeOffset:</p>
  
  <pre><code>TimeZone tz = TimeZone.getDefault();
  
  //deal with GMT weirdness
  if (tz.getRawOffset() == 0)
      return tz.getRawOffset() + tz.getDSTSavings();
  else
      return tz.getRawOffset();
  </code></pre>
  
  <p>I would think that I need something like:</p>
  
  <pre><code>else if(tz.inDaylightTime(new Date()))
      return tz.getRawOffset() + tz.getDSTSavings();
  </code></pre>
  
  <p>But if I do that, then Eastern time shows 1 hour less than it should, and Alaskan time shows 2 hours less. If I do the opposite: (- instead of +)</p>
  
  <pre><code>else if(tz.inDaylightTime(new Date()))
      return tz.getRawOffset() - tz.getDSTSavings();
  </code></pre>
  
  <p>Then Eastern time is 1 hour more than it should be, but Alaskan time is correct.</p>
  
  <p><strong>ADDENDUM:</strong> </p>
  
  <p>I've also tried using <code>tz.getOffset(new Date().getTime())</code> in each of those situations instead of <code>tz.getRawOffset()</code>. This was actually the first thing that I tried, because according to Google's documentation, this function is supposed to handle DST for you. </p>
  
  <p><strong>END ADDENDUM</strong></p>
  
  <p>I've also tried using Calendars, like this:</p>
  
  <pre><code>Calendar calendar = GregorianCalendar.getInstance();
  
  return calendar.get(Calendar.ZONE_OFFSET);
  </code></pre>
  
  <p>This gives the correct time for EST time, but 1 hour ahead for GMT and 1 hour behind for Alaska. And I've tried this:</p>
  
  <pre><code>if(tz.inDaylightTime(new Date()))
      return calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET);
  else
      return calendar.get(Calendar.ZONE_OFFSET);
  </code></pre>
  
  <p>But this leaves EDT 1 hour short.</p>
  
  <p>I've also tried this:</p>
  
  <pre><code>return tz.getOffset(calendar.get(Calendar.ERA),
              calendar.get(Calendar.YEAR),
              calendar.get(Calendar.MONTH),
              calendar.get(Calendar.DAY_OF_MONTH),
              calendar.get(Calendar.DAY_OF_WEEK),
              calendar.get(Calendar.MILLISECOND));
  </code></pre>
  
  <p>which leaves EDT 1 hour short as well.</p>
  
  <p>And I get the same results if I use </p>
  
  <pre><code>GregorianCalendar calendar = new GregorianCalendar(tz);
  </code></pre>
  
  <p>instead of </p>
  
  <pre><code>Calendar calendar = GregorianCalendar.getInstance();
  </code></pre>
  
  <p>How do I do this correctly???</p>