iOS开发之NSDateFormatter的NSLocale使用en_US_POSIX还是en_US
来源:互联网 发布:tfboys背包淘宝 编辑:程序博客网 时间:2024/05/18 17:24
iOS SDK提供的日期时间格式化对象需要使用到NSLocale对象来控制日期和时间的显示,en_US为标准的格式往往使用的最多,但是习惯使用Java或C#的朋友会忽略掉iOS SDK提供的另一种格式en_US_POSIX,并且两种格式运行后的效果完全一样。
参考代码;
到底使用en_US_POSIX还是en_US, Apple在SDK文档中给出了答案.
In most cases the best locale to choose is "en_US_POSIX"
因为
"en_US_POSIX" is also invariant in time (if the US, at some point in the future, changes the way it formats dates, "en_US" will change to reflect the new behaviour, but "en_US_POSIX" will not), and between machines ("en_US_POSIX" works the same on iPhone OS as it does on Mac OS X, and as it it does on other platforms).
参考链接
http://stackoverflow.com/questions/6613110/what-is-the-best-way-to-deal-with-the-nsdateformatter-locale-feature
http://developer.apple.com/library/ios/#qa/qa1480/_index.html
--------------------------------------------------------------------------------------
- 版权声明:
- 如在本页面内无特别说明,本文内容均为[李大仁博客]原创,本文版权归[李大仁博客]所有。
- 欢迎转载,转载请务必在文章页面明显位置提供原文链接并注明出处。欢迎您在转载本文时保留本段声明。
- 文章标题:iOS开发之NSDateFormatter格式化日期NSLocale使用en_US_POSIX还是en_US
- 独立博客:李大仁博客
- 永久链接:http://www.lidaren.com/archives/811
--------------------------------------------------------------------------------------
以上内容由博客自动发布工具自动发布,最终显示内容和效果会与原文内容有所偏差,敬请谅解。
参考代码;
NSDateFormatter *formatter1 = [[[NSDateFormatter alloc] init] autorelease];
[formatter1 setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease]];
NSDateFormatter *formatter2 = [[[NSDateFormatter alloc] init] autorelease];
[formatter2 setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease]];
[formatter1 setDateFormat:@"yyyy/MM/dd HH:mm:ss"];
[formatter2 setDateFormat:@"yyyy/MM/dd HH:mm:ss"];
NSDate *date = [NSDate date];
NSLog(@"formatter1:%@",[formatter1 stringFromDate:date]);
NSLog(@"formatter2:%@",[formatter2 stringFromDate:date]);
到底使用en_US_POSIX还是en_US, Apple在SDK文档中给出了答案.
In most cases the best locale to choose is "en_US_POSIX"
因为
"en_US_POSIX" is also invariant in time (if the US, at some point in the future, changes the way it formats dates, "en_US" will change to reflect the new behaviour, but "en_US_POSIX" will not), and between machines ("en_US_POSIX" works the same on iPhone OS as it does on Mac OS X, and as it it does on other platforms).
参考链接
http://stackoverflow.com/questions/6613110/what-is-the-best-way-to-deal-with-the-nsdateformatter-locale-feature
http://developer.apple.com/library/ios/#qa/qa1480/_index.html
--------------------------------------------------------------------------------------
- 版权声明:
- 如在本页面内无特别说明,本文内容均为[李大仁博客]原创,本文版权归[李大仁博客]所有。
- 欢迎转载,转载请务必在文章页面明显位置提供原文链接并注明出处。欢迎您在转载本文时保留本段声明。
- 文章标题:iOS开发之NSDateFormatter格式化日期NSLocale使用en_US_POSIX还是en_US
- 独立博客:李大仁博客
- 永久链接:http://www.lidaren.com/archives/811
--------------------------------------------------------------------------------------
以上内容由博客自动发布工具自动发布,最终显示内容和效果会与原文内容有所偏差,敬请谅解。
0 0
- iOS开发之NSDateFormatter的NSLocale使用en_US_POSIX还是en_US
- ios开发NSLocale的一些方法
- ios开发NSLocale的一些方法
- IOS开发:NSDateFormatter的问题
- iOS NSDateFormatter 日期的使用
- iOS 之NSLocale Class
- iOS学习之NSLocale
- NSDate,NSDateFormatter,NSLocale
- IOS开发之----NSDateFormatter调整时间格式
- 17 Foundation框架之NSDate、NSDateFormatter、NSDateComponents、NSCalendar、NSLocale、NSTimer
- NSlocale的使用
- IOS开发—NSDateFormatter
- ios开发系列之NSDate,NSDateFormatter,NSDateComponents和NSCalendar
- IOS开发之NSDateFormatter处理日期格式详解
- ios开发--NSDate与NSDateFormatter的相关用法
- iOS开发--NSDate与NSDateFormatter的相关用法【转】
- NSDateFormatter的使用
- NSDate, NSDateFormatter的使用
- iOS开发之Relaese时关闭NSLog使之不在控制台显示
- 银行交易系统 MyJdbcTools
- iOS开发之让UITableView滚动控制并返回到最顶端
- 将CHM文件转换为HTML文件
- DTD算法
- iOS开发之NSDateFormatter的NSLocale使用en_US_POSIX还是en_US
- iOS开发之自定义系统的UIAlertView调整Alert字体
- 斐波那契系列问题
- USB2.0 A型、B型、Mini和Micro接口定义及封装
- Spring-jdbc:JdbcTemplate使用简介
- iOS开发之自定义系统的UIActionSheet修改按钮的属性
- iOS开发之UITabBarController记录上一次选中的tabIndex并返回
- [Linux]CentOS配置修改网络连接配置
- Ext.util.Format.date,分钟与月份的误会