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

  • <small id='yYMDP'></small><noframes id='yYMDP'>

    1. <legend id='yYMDP'><style id='yYMDP'><dir id='yYMDP'><q id='yYMDP'></q></dir></style></legend>
      • <bdo id='yYMDP'></bdo><ul id='yYMDP'></ul>

        <tfoot id='yYMDP'></tfoot>

        如何将日期格式化为字符串,例如“2000 年 12 月 31 日"在爪哇

        How to format date to string like quot;31st Dec, 2000quot; in Java(如何将日期格式化为字符串,例如“2000 年 12 月 31 日在爪哇)
        <legend id='d5UR4'><style id='d5UR4'><dir id='d5UR4'><q id='d5UR4'></q></dir></style></legend>
            <tbody id='d5UR4'></tbody>

            <bdo id='d5UR4'></bdo><ul id='d5UR4'></ul>
          • <small id='d5UR4'></small><noframes id='d5UR4'>

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

                  本文介绍了如何将日期格式化为字符串,例如“2000 年 12 月 31 日"在爪哇的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我尝试使用 SimpleDateFormat 类来执行此操作,但我没有找到任何在一天之后放置 'st' 的选项.我只能得到 '31 Dec, 2000'

                  I tried to use the SimpleDateFormat class to do this, But I did not find any options that put a 'st' after the day. I could only get '31 Dec, 2000'

                  如何格式化 "31st Dec, 2000" .我有以毫秒为单位的日期.

                  How to format like "31st Dec, 2000" . I have the date in milliseconds.

                  Java 中是否有任何 API 可以让我们以这种方式格式化日期?

                  Is there any API in java that lets us format a date this way?

                  推荐答案

                  一个带switch case的简单函数,这样做

                  A simple function with switch case, do this

                  Public String getDateSuffix( int day) { 
                          switch (day) {
                              case 1: case 21: case 31:
                                     return ("st");
                  
                              case 2: case 22: 
                                     return ("nd");
                  
                              case 3: case 23:
                                     return ("rd");
                  
                              default:
                                     return ("th");
                          }
                  }
                  

                  这篇关于如何将日期格式化为字符串,例如“2000 年 12 月 31 日"在爪哇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)

                      <tfoot id='PW067'></tfoot>
                        <bdo id='PW067'></bdo><ul id='PW067'></ul>
                        <legend id='PW067'><style id='PW067'><dir id='PW067'><q id='PW067'></q></dir></style></legend>

                      • <small id='PW067'></small><noframes id='PW067'>

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