iOS15.4严重bug
[NSDateFormatter stringFromDate:]返回错误日期格式
问题复现
1.把手机升级到iOS15.4
2.进入系统设置->通用->日期和时间->关闭24小时制
项目中执行:
NSDate *date = [NSDate date];
NSDateFormatter *format = [[NSDateFormatter alloc] init];
format.dateFormat = @"yyyy-MM-dd HH:mm:ss";
NSString *str = [format stringFromDate:date];
NSLog(@"str------>%@", str);
结果: 2022-04-15 09:28:29.782359+0800 xxx[79728:2840600] str------>2022-04-15 上午9:28:29
多了个“上午”??没有返回想要的格式!
其它情况正常
目前解决办法
format.locale = [[NSLocale alloc]initWithLocaleIdentifier:[NSLocale preferredLanguages].firstObject];
同样的bug
# iOS15.4[NSDateFormatter dateFromString:]返回nil