Here you can find the source of getDayOfMonth(Date p_date)
@SuppressWarnings("static-access") public static long getDayOfMonth(Date p_date) throws ParseException
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { @SuppressWarnings("static-access") public static long getDayOfMonth(Date p_date) throws ParseException { int year = getYearOfDate(p_date); int month = getMonthOfDate(p_date) - 1; int day = getDayOfDate(p_date); int hour = getHourOfDate(p_date); int minute = getMinuteOfDate(p_date); int second = getSecondOfDate(p_date); Calendar l_calendar = new GregorianCalendar(year, month, day, hour, minute, second); return l_calendar.getActualMaximum(l_calendar.DAY_OF_MONTH); }/*from w w w . jav a2 s . c om*/ public static int getYearOfDate(java.util.Date p_date) { java.util.Calendar c = java.util.Calendar.getInstance(); c.setTime(p_date); return c.get(java.util.Calendar.YEAR); } public static int getMonthOfDate(java.util.Date p_date) { java.util.Calendar c = java.util.Calendar.getInstance(); c.setTime(p_date); return c.get(java.util.Calendar.MONTH) + 1; } public static int getDayOfDate(java.util.Date p_date) { java.util.Calendar c = java.util.Calendar.getInstance(); c.setTime(p_date); return c.get(java.util.Calendar.DAY_OF_MONTH); } public static int getHourOfDate(java.util.Date p_date) { java.util.Calendar c = java.util.Calendar.getInstance(); c.setTime(p_date); return c.get(java.util.Calendar.HOUR_OF_DAY); } public static int getMinuteOfDate(java.util.Date p_date) { java.util.Calendar c = java.util.Calendar.getInstance(); c.setTime(p_date); return c.get(java.util.Calendar.MINUTE); } public static int getSecondOfDate(java.util.Date p_date) { java.util.Calendar c = java.util.Calendar.getInstance(); c.setTime(p_date); return c.get(java.util.Calendar.SECOND); } }