title: Android SimpleDateFormat returning incorrect time between midnight and 1am
body: <p>SOLVED
  I have found that between midnight and 1am my device returns a time 1 hour later (the other 23 hours a day it returns correctly). More weirdly it returns correctly if I use <code>kk</code> instead of <code>HH</code> (though the resulting string is no use to me)</p>
  
  <p>Code I am running: (in this instance <code>strFormat</code> matches the hardcoded string in <code>df3</code>)</p>
  
  <pre><code>SimpleDateFormat df = new SimpleDateFormat(strFormat, Locale.US);
  SimpleDateFormat df2 = new SimpleDateFormat("yyyy-MM-dd kk:mm", Locale.US);
  SimpleDateFormat df3 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.US);
  
  Date d = c.getTime();
  String s = d.toString();
  String ret = df.format(c.getTime());
  String ret2 = df.format(new Date(System.currentTimeMillis()));
  String ret3 = df2.format(c.getTime());
  String ret4 = df3.format(c.getTime());
  String r1 = ""+c.get(Calendar.HOUR);
  </code></pre>
  
  <p>These return:</p>
  
  <pre><code>s = "Thu Jan 07 00:39:32 GMT-11:00 2016"
  ret = "2016-01-07 01:39:32"
  ret2 = "2016-01-07 01:39:32"
  ret3 = "2016-01-07 24:39"
  ret4 = "2016-01-07 01:39:32.525"
  r1 = "0"
  </code></pre>
  
  <p>After 1am these return:</p>
  
  <pre><code>s = "Thu Jan 07 01:07:09 GMT-11:00 2016"
  ret = "2016-01-07 01:07:09"
  ret2 = "2016-01-07 01:07:09"
  ret3 = "2016-01-07 01:07"
  ret4 = "2016-01-07 01:07:09.606"
  r1 = "1"
  </code></pre>
  
  <p>Any help in what I have done wrong/what is going wrong greatly appreciated.</p>
  
  <p>UPDATE</p>
  
  <p>changing code to:</p>
  
  <pre><code>SimpleDateFormat df = new SimpleDateFormat(strFormat, Locale.US);
          df.setTimeZone(TimeZone.getTimeZone("GMT"));
          SimpleDateFormat df2 = new SimpleDateFormat("yyyy-MM-dd kk:mm zzz", Locale.US);
          df2.setTimeZone(TimeZone.getTimeZone("GMT"));
          SimpleDateFormat df3 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS zzz", Locale.US);
          df3.setTimeZone(TimeZone.getTimeZone("GMT"));
          Date d = c.getTime();
          String s = d.toString();
          String ret = df.format(c.getTime());
          String ret2 = df.format(new Date(System.currentTimeMillis()));
          String ret3 = df2.format(c.getTime());
          String ret4 = df3.format(c.getTime());
          String r1 = ""+c.get(Calendar.HOUR);
          return ret;
  </code></pre>
  
  <p>I get the same results:</p>
  
  <pre><code>s = "Fri Jan 08 00:52:05 GMT 2016"
  ret = "2016-01-08 01:52:05"
  ret2 = "2016-01-08 01:52:05"
  ret3 = "2016-01-08 24:52 GMT"
  ret4 = "2016-01-08 01:52:05.169 GMT"
  r1 = "0"
  </code></pre>
  
  <p>and</p>
  
  <pre><code>s = "Fri Jan 08 01:03:23 GMT 2016"
  ret = "2016-01-08 01:03:23"
  ret2 = "2016-01-08 01:03:23"
  ret3 = "2016-01-08 01:03 GMT"
  ret4 = "2016-01-08 01:03:23.547 GMT"
  r1 = "1"
  </code></pre>
  
  <p>so the problem seems to be unrelated to TimeZone</p>