[Solved] how to return the number of days according on its month using java [duplicate]


The below code uses the java Calendar class by setting it’s month to the input month and getting its max date by getActualMaximum() method. Also it will return 29 for leap years.

public static void main(String args[]){
        int month = 6;
        Calendar cal  = Calendar.getInstance();
        cal.set(Calendar.MONTH, month-1);
        System.out.println(cal.getActualMaximum(Calendar.DATE));
    }

3

solved how to return the number of days according on its month using java [duplicate]