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

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

      2. <legend id='el59I'><style id='el59I'><dir id='el59I'><q id='el59I'></q></dir></style></legend>

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

        基于android上用户区域设置的日期格式

        Date formatting based on user locale on android(基于android上用户区域设置的日期格式)
      3. <small id='guDRh'></small><noframes id='guDRh'>

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

                    <tbody id='guDRh'></tbody>
                  本文介绍了基于android上用户区域设置的日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想根据用户区域设置显示出生日期.在我的应用程序中,我的字段之一是出生日期,目前的格式为 dd/mm/yyyy.所以如果用户改变了他的语言环境,日期格式也应该相应地改变.任何指针或代码示例都会真正帮助我克服这个问题.

                  I want to display a date of birth based on the user locale. In my application, one of my fields is the date of birth, which is currently in the format dd/mm/yyyy. So if the user changes his locale, the date format should also change accordingly. Any pointers or code samples would really help me to overcome the problem.

                  推荐答案

                  你可以使用DateFormat 类,根据用户区域设置格式化日期.

                  You can use the DateFormat class that formats a date according to the user locale.

                  例子:

                  String dateOfBirth = "26/02/1974";
                  SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
                  Date date = null;
                  try {
                      date = sdf.parse(dateOfBirth);
                  } catch (ParseException e) {
                      // handle exception here !
                  }
                  java.text.DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(context);
                  String s = dateFormat.format(date);
                  

                  您可以使用不同的方法 getLongDateFormatgetMediumDateFormat,具体取决于您想要的详细程度.

                  You can use the different methods getLongDateFormat, getMediumDateFormat depending on the level of verbosity you would like to have.

                  这篇关于基于android上用户区域设置的日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)
                  Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)
                  Resume game cocos2d(恢复游戏 cocos2d)
                  Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))
                  Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)
                  How to convert 32 bit PNG to RGB565?(如何将 32 位 PNG 转换为 RGB565?)
                    <tbody id='V78sm'></tbody>

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

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

                    • <bdo id='V78sm'></bdo><ul id='V78sm'></ul>

                          <legend id='V78sm'><style id='V78sm'><dir id='V78sm'><q id='V78sm'></q></dir></style></legend><tfoot id='V78sm'></tfoot>