Skip to content

Instantly share code, notes, and snippets.

@eddieespinal
Created May 19, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eddieespinal/f6ce7c0349ebd165f5f6 to your computer and use it in GitHub Desktop.
Save eddieespinal/f6ce7c0349ebd165f5f6 to your computer and use it in GitHub Desktop.
// These functions are not thread-safe, nor are the NSDateFormatter instances they return. // Make sure that this function and the formatter are called on only one thread at a time.
#pragma mark - DATE CONVERSION:
// These functions are not thread-safe, nor are the NSDateFormatter instances they return.
// Make sure that this function and the formatter are called on only one thread at a time.
static NSDateFormatter* getISO8601Formatter() {
static NSDateFormatter* sFormatter;
if (!sFormatter) {
// Thanks to DenNukem's answer in http://stackoverflow.com/questions/399527/
sFormatter = [[NSDateFormatter alloc] init];
sFormatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ss.SSSXXX";
sFormatter.calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
sFormatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
}
return sFormatter;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment