<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上用户区域设置的日期格式

        时间:2023-09-12
      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上用户区域设置的日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:为什么我们需要将委托设置为自我?为什么编译器不默认它? 下一篇:如何创建多语言安卓应用程序?

                  相关文章

                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>