How do I get days of a particular month using java.util.Calendar.I have tried the code given below, but it gives me the days for the latest month and not the month I have given as input.I don't want to use a switch case.Can anyone please help?Thanks in advance!
public static void main(String args[]) throws ParseException { Calendar cal = Calendar.getInstance(); int month = cal.get(Calendar.MONTH); int year = cal.get(Calendar.YEAR); if (month == 0) { month = 3; year = year-1; } String dateStart = "'"+ (year) +"-"+ (month) +"-1 00:00:00'"; String dateEnd = "'"+ (year) +"-"+ (month) +"-"+ cal.getMaximum(Calendar.DAY_OF_MONTH); dateEnd = dateEnd +" 23:59:59'"; System.out.println("Start and End Date : "+ dateStart +" : "+ dateEnd);}