I have this code which works perfectly on a simulator but on a real device it does not work.
The string it returns is nil
, why?
-(NSString*)metodoFormatoFecha:(NSString*)cadena{
NSString *trimmedString = [cadena stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceCharacterSet]];
NSString *newString = [[trimmedString componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]] componentsJoinedByString:@""];
//newString contanain -> 2015-07-28T10:41:01-04:00
NSDateFormatter *dateStringParser = [[NSDateFormatter alloc] init];
[dateStringParser setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.ZZZZ"];
NSDate *date = [dateStringParser dateFromString:newString];
NSDateFormatter *labelFormatter = [[NSDateFormatter alloc] init];
[labelFormatter setDateFormat:@"yyyy-MM-dd'\n'HH:mm:ss\nZZZZ"];
NSString *FechaConFormato = [labelFormatter stringFromDate:date];
return FechaConFormato;
}