- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试解析这个日期时间戳
开始串:
Wed, 11 Sep 2013 08:51:41 EEST
EEST
dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_EN_POSIX"]];
[dateFormat setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"EEST"]];
[dateFormat setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss V"];
dateFromString = [dateFormat dateFromString:beginString];
最佳答案
您对这个问题的解决方案是将语言环境更改为 en_GB
并且日期格式化程序将能够正确解析您的日期字符串。
这是 Apple 开发人员错误报告团队对 radar #9944011 的回复的解释。 :
This is an intentional change in iOS 5. The issue is this: With the short formats as specified by z (=zzz) or v (=vvv), there can be a lot of ambiguity. For example, "ET" for Eastern Time" could apply to different time zones in many different regions. To improve formatting and parsing reliability, the short forms are only used in a locale if the "cu" (commonly used) flag is set for the locale. Otherwise, only the long forms are used (for both formatting and parsing). This is a change in open-source CLDR 2.0 / ICU 4.8, which is the basis for the ICU in iOS 5, which in turn is the basis of NSDateFormatter behavior.
For the "en" locale (= "en_US"), the cu flag is set for metazones such as Alaska, America_Central, America_Eastern, America_Mountain, America_Pacific, Atlantic, Hawaii_Aleutian, and GMT. It is not set for Europe_Central.
However, for the "en_GB" locale, the cu flag is set for Europe_Central.
So, a formatter set for short timezone style "z" or "zzz" and locale "en" or "en_US" will not parse "CEST" or "CET", but if the locale is instead set to "en_GB" it will parse those. The "GMT" style will be parsed by all.
If the formatter is set for the long timezone style "zzzz", and the locale is any of "en", "en_US", or "en_GB", then any of the following will be parsed, because they are unambiguous:
"Pacific Daylight Time" "Central European Summer Time" "Central European Time"
关于ios - Nsdateformatter + 时区问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18763420/
我在 iOS 6 上使用 xcode 4.5(4G182)。NSDateFormatter 在 iOS 6 中显示错误的年份,如何解决? NSDateFormatter *dateFormatter
我在 iOS 6 上使用 xcode 4.5(4G182)。NSDateFormatter 在 iOS 6 中显示错误的年份,如何解决? NSDateFormatter *dateFormatter
我正在尝试创建一个 TableViewCell,就像 iPhone 上的 Notes 应用程序中的那样。标题在左侧,时间在右侧,紧挨着披露者指示符。 看起来像那样的 tableView。我知道我必须使
我有一个用于“从”和“到”字段的日期选择器,我想要减法的结果。例如:toValue-fromValue,结果以小时为单位。如何做到这一点? 最佳答案 可以使用timeIntervalSinceDate
我简单地尝试重新格式化日期: NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; NSDate *date = [[NSDat
在 Instrument 的帮助下,我发现以下代码段存在内存泄漏。仪器显示 NSDateFormatter 此处泄漏内存。 - (NSDate*) dateSelected{ if(selectedD
当用户未使用公历作为 iPhone 的默认日历时,我在使用 NSDateFormatter 时遇到问题。 NSString *testString = @"2011-01-14"; NSDateFor
以下日期/时间的 NSDateFormatter 字符串是什么:02/22/2011 10:43:00 AM 基本上我想要的是读取字符串02/22/2011 19:00:23 PM,将其转换为NSDa
我正在尝试创建一个格式化程序,将显示的日期格式转换为 NSDate 对象: NSString *dateStr = @"2010-06-21T19:00:00-05:00"; NSDateFormat
我有一个带有 NSDateFormatter 的 NSTextField。格式化程序接受“mm/dd/yy”。 可以自动补全日期吗?因此,用户可以输入“mm”,格式化程序将完成当前月份和年份。 最佳答
我正在从表示日期的文本中提取字符串。它们看起来像这样: Monday August 16, 2010 05:28 AM EST 我正在尝试使用 NSDateFormatter 来解析它们。我已将其格式
我有一个应用于 NSTextFieldCell 的 10.4 样式日期格式化程序。我调用 setTwoDigitStartDate: (尝试使用纪元日期和“引用”日期),但是当我输入带有两位数年份的日
在打开 doesRelativeDateFormatting 的情况下使用 NSDateFormatter 时,所有相对格式似乎都相对于当前系统时间。我想使用相对格式设置日期,例如“今天”或“明天”,
我想从日期获取 NSString,日期格式如下: MMEEEY ww 问题出在“ww”,即一年中的第几周。我必须将此格式与从后台获取的另一种格式进行比较。但后台的第一个工作日是星期一,而 iOS 的第
我的日期格式化程序返回nil表示一个特定日期:“1998年3月20日”。 + (NSDate*)dateFromString:(NSString*)date { NSDateFormatter
我知道这篇文章可能一式三份,但是到目前为止,关于现有线程的所有答案都没有帮助我。 我试图从字符串中获取NSDate值,但结果一直是nil。这是我的代码 NSString * dateString =
Crashlytics服务报告一些崩溃(大约30个崩溃/ 18个用户进行1000个 session ) 这是我的代码: var brutDate: String = "" brutDate () (
我正在尝试解析这个日期时间戳 开始串: Wed, 11 Sep 2013 08:51:41 EEST 这个问题只有 EEST , 我试过 z 或 zzz 或 V,什么也没发生。日期格式化程序始终为 N
这个问题在这里已经有了答案: NSDate Format outputting wrong date (5 个回答) 8年前关闭。 我正在使用下面的代码,但它给了我提前一天 date 。 示例 :将输
使用设备上用户的currentLocale,我想要一种与NSDateFormatterFullStyle生成的日期格式完全相同的日期格式减去年份: [dateFormatter setDateStyl
我是一名优秀的程序员,十分优秀!