In Java we can use the Calendar class to get day_of_month, day_of_week etc. Last day of a month varies depending on the Month and on leap year we have extra day in February. So to figure out the last day of any given month in a year, we write some code which is apparently simple.
Calendar object allows us to manipulate days, go forward or backward on the Calendar, add days, hours, minutes or seconds to any given time etc. We will use these capabilities of Calendar class to get our last_of_month.