This example will show how to find the total number of days in a month using java, java 8 and joda time. Each snippet will use the the month of April to find that it has 30 days in month.
Straight up Java
In this snippet will use java to find the maximum number of days in a month by calling Calendar getActualMaximum and passing the field number representing a month.
Java 8 LocalDate lengthOfMonth method will return the the number of days in a month. In the snippet below, a date of April will return 30 days. Another way to find total number of days in a month would be to call LocalDate.getMonth() which will return the Month enum and then call the length which will return length of month in days.
Using joda we can find the total number of days in a given month by calling the getMaximumValue method.