Here you can find the source of getDayOfMonth(Date date)
public final static long getDayOfMonth(Date date) throws ParseException
//package com.java2s; import java.text.ParseException; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { public final static long getDayOfMonth(Date date) throws ParseException { int year = getYearOfDate(date); int month = getMonthOfDate(date) - 1; int day = getDayOfDate(date); int hour = getHourOfDate(date); int minute = getMinuteOfDate(date); int second = getSecondOfDate(date); Calendar l_calendar = new GregorianCalendar(year, month, day, hour, minute, second); return l_calendar.getActualMaximum(Calendar.DAY_OF_MONTH); }//from w ww .j a v a 2s .com public final static int getYearOfDate(Date date) { return getFieldValueByDate(date, Calendar.YEAR); } public final static int getMonthOfDate(Date date) { return getFieldValueByDate(date, Calendar.MONTH) + 1; } public final static int getDayOfDate(Date date) { return getFieldValueByDate(date, Calendar.DAY_OF_MONTH); } public final static int getHourOfDate(Date date) { return getFieldValueByDate(date, Calendar.HOUR_OF_DAY); } public final static int getMinuteOfDate(Date date) { return getFieldValueByDate(date, Calendar.MINUTE); } public final static int getSecondOfDate(Date date) { return getFieldValueByDate(date, Calendar.SECOND); } /** * get field value by date and the field, like get the year of a date * * @param date * @param field * @return */ public final static int getFieldValueByDate(Date date, int field) { Calendar c = Calendar.getInstance(); c.setTime(date); return c.get(field); } }