The simplest way is to construt a new GregorianCalendar
instance, see below:
Calendar cal = new GregorianCalendar(2013, 5, 0);
Date date = cal.getTime();
DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
System.out.println("Date : " + sdf.format(date));
Output:
Date : 2013-05-31
Attention:
month the value used to set the MONTH calendar field in the calendar. Month value is 0-based e.g. 0 for January.