Java Utililty Methods Day in Month

List of utility methods to do Day in Month

Description

The list of methods to do Day in Month are organized into topic(s).

Method

StringtoMonthFirstDay(String month)
to Month First Day
return month + "-01";
voidvalidateDayOfMonth(int day)
validate Day Of Month
if ((day < 1 || day > 31) && day != LAST_DAY_OF_MONTH) {
    throw new IllegalArgumentException("Invalid day of month.");
voidvalidateMonthDay(int nDate)
validate Month Day
if ((nDate > 28) || (nDate < 1)) {
    throw new IndexOutOfBoundsException("nDate must be between 1 and 28. " + nDate + " was passed.");
intweekOfMonth(int dayCount, int commonMonthIndex)
Answer the nth week of the given month
int daysIntoMonth = dayCount - FirstDayOfMonth[commonMonthIndex - 1] + 1;
return (daysIntoMonth / 7) + (((daysIntoMonth % 7) > 0) ? 1 : 0);