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

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

                  相关文档推荐

                  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屋-程序员
                  quot;Auto Layout still required after executing -layoutSubviewsquot; with UITableViewCell subclass(“执行 -layoutSubviews 后仍需要自动布局带有 UITableViewCell 子类)
                  What is quot;Constrain to marginquot; in Storyboard in Xcode 6(什么是“限制边距?在 Xcode 6 的情节提要中)
                  Can#39;t get to work CocoaPods and Yosemite(无法开始工作 CocoaPods 和 Yosemite)
                    <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>