How to display First three letters of the month in android datepicker

老子叫甜甜 提交于 2020-01-03 07:10:06

问题


In date Picker I tried to get month in letter others are in integer It's returning full name of the month. But i want first threes letters of the month.

i tried:

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

output: 2013-October-18

I want output as : 2013-Oct-18


回答1:


Use MMM, like this SimpleDateFormat("yyyy-MMM-dd ")




回答2:


Try the following code.Hopefully this will work...

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


来源:https://stackoverflow.com/questions/33229011/how-to-display-first-three-letters-of-the-month-in-android-datepicker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!