title: problems with Java daylight savings time
body: <p>I have a Java app that needs to be cognizant of the time zone.  When I take a Unix epoch time and try to convert it into a timestamp to use for an Oracle SQL call, it is getting the correct timezone, but the timezone "useDaylightTime" value is not correct, i.e., it is currently returning "true", when we are NOT in DST (I am in Florida in TZ "America/New_York").</p>
  
  <p>This is running on Red Hat Linux Enterprise 6, and as far as I can tell, it <em>is</em> correctly set up for the timezone, e.g. 'date' returns:
    Wed Nov 28 12:30:12 EST 2012</p>
  
  <p>I can also see, using the 'zdump' utility, that the current value for 'isdst' is 0.</p>
  
  <p>My Java version is 1.6.0_31.</p>
  
  <p>I have Googled this and seen the numerous issues this has caused, but many of them simply say to set the TZ manually, but my issue is not the TZ, but the fact that the default TZ has the "isDaylight" set to 'true'.  I believe this is causing my query to return data that is one hour off (I can see that it is).</p>
  
  <p>Here is a simple code piece I have run to try and reproduce this in the simplest way possible:</p>
  
  <pre><code>public class TZdefault {
  
      public static void main(String[] args) throws IOException {
  
              long startTime = System.currentTimeMillis()/1000;
  
              Calendar start = Calendar.getInstance();
              start.setTimeInMillis(startTime);
  
              start.setTimeZone(TimeZone.getDefault());
  
              System.out.println("Start UTC: " + start + "ms: " + start.getTimeInMillis());
              System.out.println("use daylight: " + start.getTimeZone().useDaylightTime());
  
      } // end main
  
  
  }  // end class
  </code></pre>
  
  <p>One final thing.  If in my code I set the TZ to "EST", it of course <em>does</em> return a TZ with 'isDaylight' set to False.  But that is not a good solution.</p>
  
  <p>I wanted to add some more detail that I had been hoping to hide.</p>
  
  <p>I have records in an Oracle 11g database that use TIMESTAMP with TIMEZONE fields.  I am simply doing JDBC queries where two of the parameters are using BETWEEN a start timestamp and end timestamp.</p>
  
  <p>When I query this table, I am using a prepared statement that is using a Calendar entry, the sole purpose of which was to try and manipulate the timezone.  The bottom line is that I am doing a pstmt.setTimestamp() call using the 'getTimeInMillis' method for the start and end time after the "default" timezone was applied.  The log output shows that in fact it is putting in the correct milliseconds, but the returned SQL results are clearly off by one hour exactly!</p>
  
  <p>I am still trying to verify that there is not an issue on the data insertion side as well.</p>
  
  <p>But I have a lot of debug information, and it looks like I am asking for the correct time in my JDBC query.</p>