Month name as a string

前端 未结 11 2143
悲哀的现实
悲哀的现实 2020-11-27 02:49

I\'m trying to return the name of the month as a String, for instance \"May\", \"September\", \"November\".

I tried:

int month = c.get(Calendar.MONTH         


        
11条回答
  •  清酒与你
    2020-11-27 03:38

    As simple as this

    mCalendar = Calendar.getInstance();    
    String month = mCalendar.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.getDefault());
    

    Calendar.LONG is to get the full name of the month and Calendar.SHORT gives the name in short. For eg: Calendar.LONG will return January Calendar.SHORT will return Jan

提交回复
热议问题