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

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

    1. <tfoot id='sFkdd'></tfoot>
        <bdo id='sFkdd'></bdo><ul id='sFkdd'></ul>
      <legend id='sFkdd'><style id='sFkdd'><dir id='sFkdd'><q id='sFkdd'></q></dir></style></legend>

      1. 如何确定语言环境的日期格式是月/日还是日/月?

        How to determine if locale#39;s date format is Month/Day or Day/Month?(如何确定语言环境的日期格式是月/日还是日/月?)

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

                <small id='3hH7x'></small><noframes id='3hH7x'>

                  本文介绍了如何确定语言环境的日期格式是月/日还是日/月?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在我的 iPhone 应用中,我希望能够确定用户区域设置的日期格式是月/日(即 1/5 表示 1 月 5 日)还是日/月(即 5/1 表示 1 月 5 日).我有一个自定义 NSDateFormatter 不使用基本格式之一,例如 NSDateFormatterShortStyle (11/23/37).

                  In my iPhone app, I'd like to be able to determine if the user's locale's date format is Month/Day (i.e. 1/5 for January fifth) or Day/Month (i.e. 5/1 for January fifth). I have a custom NSDateFormatter which does not use one of the basic formats such as NSDateFormatterShortStyle (11/23/37).

                  在理想情况下,我想使用 NSDateFormatterShortStyle,但不显示年份(仅显示月份和日期#).完成此任务的最佳方法是什么?

                  In an ideal world, I want to use NSDateFormatterShortStyle, but just not display the year (only month & day#). What's the best way to accomplish this?

                  推荐答案

                  你要使用NSDateFormatter的+dateFormatFromTemplate:options:locale:

                  You want to use NSDateFormatter's +dateFormatFromTemplate:options:locale:

                  这是一些 Apple 示例代码:

                  Here is some Apple sample code:

                  NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
                  NSLocale *gbLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_GB"];
                  
                  NSString *dateFormat;
                  NSString *dateComponents = @"yMMMMd";
                  
                  dateFormat = [NSDateFormatter dateFormatFromTemplate:dateComponents options:0 locale:usLocale];
                  NSLog(@"Date format for %@: %@",
                      [usLocale displayNameForKey:NSLocaleIdentifier value:[usLocale localeIdentifier]], dateFormat);
                  
                  dateFormat = [NSDateFormatter dateFormatFromTemplate:dateComponents options:0 locale:gbLocale];
                  NSLog(@"Date format for %@: %@",
                      [gbLocale displayNameForKey:NSLocaleIdentifier value:[gbLocale localeIdentifier]], dateFormat);
                  
                  // Output:
                  // Date format for English (United States): MMMM d, y
                  // Date format for English (United Kingdom): d MMMM y
                  

                  这篇关于如何确定语言环境的日期格式是月/日还是日/月?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  iOS AutoLayout - get frame size width(iOS AutoLayout - 获取帧大小宽度)
                  Auto layout constraints issue on iOS7 in UITableViewCell(UITableViewCell中iOS7上的自动布局约束问题)
                  How to resize superview to fit all subviews with autolayout?(如何调整超级视图的大小以适应所有具有自动布局的子视图?)
                  Springs in Auto Layout: Distribute views evenly, with constraints, in Xcode 5(自动布局中的弹簧:在 Xcode 5 中使用约束均匀分布视图)
                  reloadData() of UITableView with Dynamic cell heights causes jumpy scrolling(具有动态单元格高度的 UITableView 的 reloadData() 导致跳跃滚动)
                  What is NSLayoutConstraint quot;UIView-Encapsulated-Layout-Heightquot; and how should I go about forcing it to recalculate cleanly?(什么是 NSLayoutConstraint“UIView-Encapsulated-Layout-Height?我应该如何强制它干净地重新计算?) - IT屋-程序员

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

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

                          <tfoot id='D11tT'></tfoot>

                            <tbody id='D11tT'></tbody>
                            <bdo id='D11tT'></bdo><ul id='D11tT'></ul>