Improper result of SimpleDateFormat
问题 I want to convert Tue Jun 01 00:00:00 IST 112 into 01-JUN-2012 I used Calendar calendar = new GregorianCalendar(year, 6, Calendar.DAY_OF_MONTH); Date maxDate=new Date(); maxDate=calendar.getTime(); calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH)); SimpleDateFormat s=new SimpleDateFormat("dd-mmm-yyyy"); s.format(maxDate); But I get 30-000-0112 回答1: Use CAPITAL M for month, SimpleDateFormat s=new SimpleDateFormat("dd-MMM-yyyy"); Also you are setting date