title: Joda-Time, Daylight Saving Time change and date time parsing
body: <p>I have the following problem using <a href="http://www.joda.org/joda-time/" rel="nofollow">Joda-Time</a> for parsing and producing date and time around <a href="https://en.wikipedia.org/wiki/Daylight_saving_time" rel="nofollow">Daylight Saving Time</a> (DST) hours. Here is an example (please, note that March 30th 2008 is Daylight Saving change in Italy):</p>
  
  <pre><code>DateTimeFormatter dtf = DateTimeFormat.forPattern("dd/MM/yyyy HH:mm:ss");
  DateTime x = dtf.parseDateTime("30/03/2008 03:00:00");
  int h = x.getHourOfDay();
  System.out.println(h);
  System.out.println(x.toString("dd/MM/yyyy HH:mm:ss"));
  DateTime y = x.toDateMidnight().toDateTime().plusHours(h);
  System.out.println(y.getHourOfDay());
  System.out.println(y.toString("dd/MM/yyyy HH:mm:ss"));
  </code></pre>
  
  <p>I get the following output:</p>
  
  <pre><code>3
  30/03/2008 03:00:00
  4
  30/03/2008 04:00:00
  </code></pre>
  
  <p>When i parse hour I get hour is 3. In my data structure I save the day storing midnight time, and then I have some value for each hour of the day (0-23). Then, when I write out the date, I re-compute the full date time making midnight plus hour. When I sum 3 hours to my midnight I get 04:00:00! And if I parse it again, I get hour 4! </p>
  
  <p>Where is my mistake? Is there some way to get hour 2 when I parse or get hour three when I print out?</p>
  
  <p>I have also tried to build output by hand:</p>
  
  <pre><code>String.format("%s %02d:00:00", date.toString("dd/MM/yyyy"), h);
  </code></pre>
  
  <p>but in this case for hour 2, I produce 30/03/2008 02:00:00 which is not a valid date (since hour 2 does not exist) and cannot be parsed any more.</p>
  
  <p>Thank you in advance for your help.
  Filippo</p>