问题
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