Sim*_*mon 37 nsdateformatter ios6
即时通讯使用xcode 4.5(4G182)与iOS 6. NSDateFormatter在iOS 6中显示错误年份,如何解决?
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:@"YYYY-MM-dd"];
NSString *str = [dateFormatter stringFromDate:[NSDate date]];
NSLog(@"%@ == %@",str,[[dateFormatter dateFromString:str] description]);
Run Code Online (Sandbox Code Playgroud)
打印出来" 2012 -09-14 == 2011 -09-13 16:00:00 +0000"
Joa*_*son 116
YYYY是不一样的yyyy.
`y`: Year
`Y`: Year (in "Week of Year" based calendars). This year designation is used in
ISO year-week calendar as defined by ISO 8601, but can be used in
non-Gregorian based calendar systems where week date processing is desired.
May not always be the same value as calendar year.
Run Code Online (Sandbox Code Playgroud)
有效的句子是最后一句.请yyyy改用.
有关使用时年份值如何以及为何可能出现偏差的详细信息YYYY:
ISO周编号年从第01周的第一天(星期一)开始,到新ISO年份之前的星期日结束(因此没有重叠或差距).它包括52或53 整周.ISO周编号年份数与周五,周六和周日,或周六和周日,或周日,传统公历年开始时的传统公历年数不同(在传统公历年末(即下一个ISO周的第01周),周一,周二和周三,或周一和周二,或仅周一,结束前一个ISO周编号年份 - 数年).对于星期四,ISO周编号年份编号始终等于传统的公历年份编号.
例子:
2008年12 月 29日星期一写成" 2009- W01-1"
2010年 1 月 3日星期日写成" 2009- W53-7"
来自https://en.wikipedia.org/wiki/ISO_8601#Week_dates (添加了粗体样式)
| 归档时间: |
|
| 查看次数: |
9358 次 |
| 最近记录: |