• <legend id='dyowY'><style id='dyowY'><dir id='dyowY'><q id='dyowY'></q></dir></style></legend>

    <small id='dyowY'></small><noframes id='dyowY'>

      <bdo id='dyowY'></bdo><ul id='dyowY'></ul>

    1. <tfoot id='dyowY'></tfoot>

      <i id='dyowY'><tr id='dyowY'><dt id='dyowY'><q id='dyowY'><span id='dyowY'><b id='dyowY'><form id='dyowY'><ins id='dyowY'></ins><ul id='dyowY'></ul><sub id='dyowY'></sub></form><legend id='dyowY'></legend><bdo id='dyowY'><pre id='dyowY'><center id='dyowY'></center></pre></bdo></b><th id='dyowY'></th></span></q></dt></tr></i><div id='dyowY'><tfoot id='dyowY'></tfoot><dl id='dyowY'><fieldset id='dyowY'></fieldset></dl></div>

        如何格式化 NSDate?

        How to format NSDate?(如何格式化 NSDate?)
      1. <small id='axHWK'></small><noframes id='axHWK'>

          <bdo id='axHWK'></bdo><ul id='axHWK'></ul>

          <legend id='axHWK'><style id='axHWK'><dir id='axHWK'><q id='axHWK'></q></dir></style></legend>
              <tbody id='axHWK'></tbody>

              1. <i id='axHWK'><tr id='axHWK'><dt id='axHWK'><q id='axHWK'><span id='axHWK'><b id='axHWK'><form id='axHWK'><ins id='axHWK'></ins><ul id='axHWK'></ul><sub id='axHWK'></sub></form><legend id='axHWK'></legend><bdo id='axHWK'><pre id='axHWK'><center id='axHWK'></center></pre></bdo></b><th id='axHWK'></th></span></q></dt></tr></i><div id='axHWK'><tfoot id='axHWK'></tfoot><dl id='axHWK'><fieldset id='axHWK'></fieldset></dl></div>
                1. <tfoot id='axHWK'></tfoot>
                  本文介绍了如何格式化 NSDate?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如何让我的 NSDate 以例如2011 年 2 月 26 日星期二"的格式显示

                  How can I get my NSDate to display in the format for example i.e "Tue Feb 26, 2011"

                  推荐答案

                  做对了.不要对您的日期格式进行硬编码.有些国家不是您所在的国家/地区,它们可能有不同的日期格式.因此,如果您想向用户显示此日期,您应该使用一种将用户区域设置考虑在内的方法.

                  Do it right. Don't hardcode your date formats. There are countries that are not your country and they might have different date formats. So if you want to show this date to the user you should use a method that takes the users locale into account.

                  您可以使用 iOS4 中引入的 dateFormatFromTemplate:options:locale: 方法来获取包含您想要的所有信息的适当格式.
                  如果你必须支持 iOS <4 您应该使用此模板方法创建一个 plist,以便为用户区域设置创建正确的日期格式.

                  You could use the dateFormatFromTemplate:options:locale: method introduced in iOS4 to get the appropriate format with all the information you want.
                  And if you have to support iOS < 4 you should create a plist with this template method to create the correct date format for the user locale.

                  NSLocale *locale = [NSLocale currentLocale];
                  NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease]; 
                  NSString *dateFormat = [NSDateFormatter dateFormatFromTemplate:@"E MMM d yyyy" options:0 locale:locale];
                  [formatter setDateFormat:dateFormat];
                  [formatter setLocale:locale];
                  NSLog(@"Formatted date: %@", [formatter stringFromDate:myDate]);
                  

                  为我的语言环境提供 So., 27. Feb 2011.
                  2011 年 2 月 27 日星期日,适用于 en_US 语言环境

                  gives So., 27. Feb 2011 for my locale.
                  and Sun, Feb 27, 2011 for the en_US locale

                  这篇关于如何格式化 NSDate?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)
                  Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)
                  Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))
                  Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)
                  Proper cocos2d scene restart?(正确的 cocos2d 场景重启?)
                  [ios.cocos2d+box2d]how to disable auto-rotation?([ios.cocos2d+box2d]如何禁用自动旋转?)
                2. <legend id='7phTp'><style id='7phTp'><dir id='7phTp'><q id='7phTp'></q></dir></style></legend>
                  <i id='7phTp'><tr id='7phTp'><dt id='7phTp'><q id='7phTp'><span id='7phTp'><b id='7phTp'><form id='7phTp'><ins id='7phTp'></ins><ul id='7phTp'></ul><sub id='7phTp'></sub></form><legend id='7phTp'></legend><bdo id='7phTp'><pre id='7phTp'><center id='7phTp'></center></pre></bdo></b><th id='7phTp'></th></span></q></dt></tr></i><div id='7phTp'><tfoot id='7phTp'></tfoot><dl id='7phTp'><fieldset id='7phTp'></fieldset></dl></div>
                    <tbody id='7phTp'></tbody>
                      <bdo id='7phTp'></bdo><ul id='7phTp'></ul>

                      <small id='7phTp'></small><noframes id='7phTp'>

                        1. <tfoot id='7phTp'></tfoot>