• <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. 如何确定语言环境的日期格式是月/日还是日/月?

        时间:2023-09-12

          <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
                  

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

                  上一篇:从右到左语言翻转 UIImageViews 下一篇:将 localizable.strings 转换为电子表格?

                  相关文章

                    <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>

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