File tree Expand file tree Collapse file tree
JSONModel/JSONModelTransformations Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -205,20 +205,27 @@ -(NSString*)JSONObjectFromNSURL:(NSURL*)url
205205}
206206
207207#pragma mark - string <-> date
208+ -(NSDateFormatter *)importDateFormatter
209+ {
210+ static dispatch_once_t once;
211+ static NSDateFormatter * dateFormatter;
212+ dispatch_once (&once, ^{
213+ dateFormatter = [[NSDateFormatter alloc ] init ];
214+ [dateFormatter setDateFormat: @" yyyy-MM-dd'T'HHmmssZZZZ" ];
215+ });
216+ return dateFormatter;
217+ }
218+
208219-(NSDate *)__NSDateFromNSString : (NSString *)string
209220{
210- NSDateFormatter *dateFormatter = [[NSDateFormatter alloc ] init ];
211221 string = [string stringByReplacingOccurrencesOfString: @" :" withString: @" " ]; // this is such an ugly code, is this the only way?
212- [dateFormatter setDateFormat: @" yyyy-MM-dd'T'HHmmssZZZZ" ];
213-
214- return [dateFormatter dateFromString: string];
222+ return [self .importDateFormatter dateFromString: string];
215223}
216224
217225-(NSString *)__JSONObjectFromNSDate : (NSDate *)date
218226{
219227 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc ] init ];
220228 [dateFormatter setDateFormat: @" yyyy-MM-dd'T'HH:mm:ssZZZ" ];
221-
222229 return [dateFormatter stringFromDate: date];
223230}
224231
You can’t perform that action at this time.
0 commit comments