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

StringgetPreMonthDayStr(String curday)
get Pre Month Day Str
int year = getYear(curday);
String monthStr = getMonth(curday);
int month = Integer.parseInt(monthStr);
if (month <= 1) {
    month = 12;
    year = year - 1;
} else
    month = month - 1;
...
StringgetStartMonthDayOfDate(String yyyyMM)
get Start Month Day Of Date
return yyyyMM + "01";
booleanis31DaysMonth(int month)

Verify if a given month has 31 days or not.

int[] months31 = { 0, 2, 4, 6, 7, 9, 11 };
for (int i = months31.length - 1; i >= 0; i--) {
    if (months31[i] == month) {
        return true;
return false;
booleanisDayMonth(String types)
is Day Month
if (DATE_TIME_LEVEL_TYPE_MONTH.equals(types))
    return true;
else
    return false;
booleanisDayOfMonth(int num)
is Day Of Month
return isNumBetween(1, num, 31);
booleanisLastDayOfMonth(int day, int month, int year)

Verify if the given date is the last day in the month.

if (month == 1) { 
    return isLeapYear(year) ? day == 29 : day == 28;
} else {
    return is31DaysMonth(month) ? day == 31 : day == 30;
intmaxDayOfMonth(int year, int month)
max Day Of Month
if (month <= 0 || month > 12) {
    return -1;
int day = 0;
switch (month) {
case 2:
    day = 28;
    break;
...
intmonthDays(int y, int m)
month Days
if ((lunarInfo[y - 1900] & (0x10000 >> m)) == 0)
    return 29;
else
    return 30;
intnumDaysInMonth(int month)
num Days In Month
switch (month) {
case 2:
    return 28;
case 4:
case 6:
case 9:
case 11:
    return 30;
...
StringpadMonthOrDay(String mod)
Pad the month or day with a leading zero
if (mod.matches("\\d{2}")) {
    return mod;
} else if (mod.matches("\\d")) {
    return "0" + mod;
} else { 
    return "";