title: Convert NSString to NSDate with new format
body: <p>This question was asked a lot, but I can't find the solution for my problem. </p>
  
  <p><strong>What I want</strong>:
  Convert a date given as a NSString into a NSDate with a complete different format.
  I want to convert <code>Tue, 31 Jul 2012 10:15:00 GMT</code> to <code>2012-07-31 10:15:00 +0000</code>.</p>
  
  <p><strong>My code</strong>:</p>
  
  <pre><code>NSString *startDateString = @"Tue, 31 Jul 2012 10:15:00 GMT"; //in real from a server
  
  NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
  [formatter setTimeZone:[NSTimeZone timeZoneWithName:@"GMT"]];
  [formatter setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss"];
  
  NSDate *startDate = [formatter dateFromString:startDateString];
  [formatter setDateFormat:@"yyy-MM-dd HH:mm:ss'Z'"];
  
  NSString *endDateString = [formatter stringFromDate:startDate];
  NSDate *endDate = [formatter dateFromString:endDateString];
  </code></pre>
  
  <p><strong>Problem</strong>:
  <code>endDate</code> is <code>nil</code>.</p>
  
  <p><strong>Edit</strong>:<br>
  Found a strange behaviour.<br>
  When I change the first dateFormat to <code>@"EEE, dd MMM yyy HH:mm:ss 'GMT'"</code> (added GMT) then the output of endDate is correct, but <strong>only</strong> in the Simulator. On the device it is still nil.<br>
  With the dateFormat without "GMT" the value is nil on the Simulator and on the Device.</p>