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

intgetDaysInMonth(int year, int month)
get Days In Month
if (month == 2) {
    if ((year % 4) == 0) {
        return 29;
return DAYS_IN_MONTH[month - 1];
int[]getDaysInMonths()
get Days In Months
return DOM.clone();
intgetDaysOfMonth(Date startdate, Date enddate, String month)
get Days Of Month
Calendar cs = Calendar.getInstance();
cs.setTime(startdate);
Calendar ce = Calendar.getInstance();
ce.setTime(enddate);
int startmonth = cs.get(Calendar.MONTH) + 1;
int endmonth = ce.get(Calendar.MONTH) + 1;
int m = Integer.parseInt(month);
Date ld = getLastDay(String.valueOf(cs.get(Calendar.YEAR)), month);
...
StringgetFirstDayOfMonth(int year, int month)
get first date of given month and year
String monthStr = month < 10 ? "0" + month : String.valueOf(month);
return year + "-" + monthStr + "-" + "01";
StringgetFirstdayOfMonth(String year, String month)
get Firstday Of Month
return year + month + "01";
intgetLastDayInMonth(int month, int year)
get Last Day In Month
int NumberOfDays = 0;
switch (month) {
case 0:
    NumberOfDays = 31;
    break;
case 1:
    if ((((year % 4) == 0) && ((year % 100) != 0)) || ((year % 400) == 0)) {
        NumberOfDays = 29;
...
intgetLastDayOfMonth(int year, int month)
get Last Day Of Month
if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
    return 31;
if (month == 4 || month == 6 || month == 9 || month == 11) {
    return 30;
if (month == 2) {
    if (isLeapYear(year)) {
...
StringgetLastDayOfMonth(String monthInitials)
get Last Day Of Month
if (monthInitials.equals("Jan"))
    return "31";
else if (monthInitials.equals("Feb"))
    return "30";
else if (monthInitials.equals("Mar"))
    return "31";
else if (monthInitials.equals("Apr"))
    return "30";
...
intgetMaxDayByMonth(String month)
get Max Day By Month
switch (Integer.parseInt(month)) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
...
intgetMaxMonthDay(int year, int month)
get Max Month Day
if (month < 7) {
    return 31; 
if (month < 12) {
    return 30; 
if (isJalaliLeapYear(year)) {
    return 30; 
...