diff --git a/DateTools/DateTools/NSDate+DateTools.m b/DateTools/DateTools/NSDate+DateTools.m index 63d16a85..35203204 100644 --- a/DateTools/DateTools/NSDate+DateTools.m +++ b/DateTools/DateTools/NSDate+DateTools.m @@ -813,12 +813,8 @@ + (NSDate *)dateWithString:(NSString *)dateString formatString:(NSString *)forma + (NSDate *)dateWithString:(NSString *)dateString formatString:(NSString *)formatString timeZone:(NSTimeZone *)timeZone { - static NSDateFormatter *parser = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - parser = [[NSDateFormatter alloc] init]; - }); - + + NSDateFormatter *parser = [[NSDateFormatter alloc] init]; parser.dateStyle = NSDateFormatterNoStyle; parser.timeStyle = NSDateFormatterNoStyle; parser.timeZone = timeZone; @@ -1619,12 +1615,8 @@ -(NSString *)formattedDateWithStyle:(NSDateFormatterStyle)style locale:(NSLocale * @return NSString representing the formatted date string */ -(NSString *)formattedDateWithStyle:(NSDateFormatterStyle)style timeZone:(NSTimeZone *)timeZone locale:(NSLocale *)locale{ - static NSDateFormatter *formatter = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - formatter = [[NSDateFormatter alloc] init]; - }); - + + NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateStyle:style]; [formatter setTimeZone:timeZone]; [formatter setLocale:locale]; @@ -1677,12 +1669,8 @@ -(NSString *)formattedDateWithFormat:(NSString *)format locale:(NSLocale *)local * @return NSString representing the formatted date string */ -(NSString *)formattedDateWithFormat:(NSString *)format timeZone:(NSTimeZone *)timeZone locale:(NSLocale *)locale{ - static NSDateFormatter *formatter = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - formatter = [[NSDateFormatter alloc] init]; - }); - + + NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:format]; [formatter setTimeZone:timeZone]; [formatter setLocale:locale];