I'm attempting to use an NSDateFormatter to format an NSDate into a specific format for communication with a server, but it seems like no matter what I do, a date that happens before 1/1/1900 ends up with a weird UTC offset. The dateFormat I'm specifying when I instantiate the formatter is: "yyyy-MM-dd'T'HH:mm:ssZ".
Here is the code I'm using to instantiate the NSDateFormatter:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"];
Farther down the line, I am passing an NSDate into the NSDateFormatter's method call, stringFromDate like so:
NSString *formattedDate = [dateFormatter stringFromDate:myDateObj];
If I pass in an NSDate of "2018-07-17 15:00:00", it gets converted to "2018-08-17T15:00:00-0400". This string is in the desired format.
However, if I pass in an NSDate of "1825-07-17 15:00:00", it gets converted to "1825-07-17T15:00:00-045602". This string is not correct.
Can anyone help shed any light on this issue and how I might be able to resolve it?