【问题标题】:How to display First three letters of the month in android datepicker如何在android datepicker中显示月份的前三个字母
【发布时间】:2015-10-20 05:53:12
【问题描述】:

在日期选择器中,我试图以字母形式获取月份,其他的则为整数 它正在返回月份的全名。但我想要本月的前三个字母。

我试过了:

SimpleDateFormat sdf = new SimpleDateFormat("yyyy,MMMM, dd ");
System.out.println(sdf.format(new SimpleDateFormat(new Date()).toString()));

输出:2013 年 10 月 18 日

我希望输出为:2013-Oct-18

【问题讨论】:

    标签: android datepicker


    【解决方案1】:

    使用MMM,像这样SimpleDateFormat("yyyy-MMM-dd ")

    【讨论】:

    • 如果我的回答对您有帮助,请点击复选标记接受它作为正确答案。
    【解决方案2】:

    试试下面的代码。希望这能奏效...

    Calendar cal=Calendar.getInstance();
    SimpleDateFormat month_date = new SimpleDateFormat("MMM");
    String month_name = month_date.format(cal.getTime());
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多