Java Online Compiler
Java get number of Days in Current Month


import java.util.*;
public class Rain {

	public static void main(String[] args)  {
		
		Calendar c = Calendar.getInstance();
		  int year = c.get(c.YEAR);
		  int month = c.get(c.MONTH);
		 
		  int date =c.get(c.DATE);
		  c.set(year, month, date);
		  int days = c.getActualMaximum(Calendar.DAY_OF_MONTH);
		  System.out.println("Number of Days: " + days);
		  
    	
    	
    	
	}
}


OUTPUT: Number of Days: 31

							
							

Date month to string conversion


import java.util.Calendar;
import java.util.Formatter;
public class Rain {
	public static void main(String[] args)  {
		      Formatter fmt = new Formatter();
		      Calendar cal = Calendar.getInstance();
		      fmt = new Formatter();
		      fmt.format("%tB %tb %tm", cal, cal, cal);
		      System.out.println(fmt);
	}
}
OUTPUT: August Aug 08