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

intgetDayOfMonth(long time)
get Day Of Month
return getDayOfYear(time) - getMonthOfYear(time) * daysInMonth;
StringgetDayOfMonth(Object millis)
get Day Of Month
Date date = new Date(Long.parseLong(millis.toString()));
String d = (new SimpleDateFormat("dd")).format(date);
return d;
intGetDayOfMonth(String aDatetime)
Get Day Of Month
String[] lParts = aDatetime.split("\\.", 0);
while (lParts[2].startsWith("0"))
    lParts[2] = lParts[2].substring(1);
return Integer.parseInt(lParts[2]);
intgetDayOfMonth(String dateKey)
Get the day of the month of the date key.
return Integer.valueOf(dateKey.substring(6, 8));
StringgetDayOfMonthSuffix(final int day)
get Day Of Month Suffix
return daySuffixes[day];
StringgetDayOrMonth(int value)
get Day Or Month
return String.format("%02d", value);
intgetDaysByMonth(int month)
get Days By Month
int day = 30;
if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
    day = 31;
} else if (month == 2) {
    day = 28;
return day;
intgetDaysInMonth(int month, int year)
get Days In Month
if (month == 0) {
    return 31;
} else if (month == 1) {
    if (isLeapYear(year)) {
        return 29;
    } else {
        return 28;
} else if (month == 2) {
    return 31;
} else if (month == 3) {
    return 30;
} else if (month == 4) {
    return 31;
} else if (month == 5) {
    return 30;
} else if (month == 6) {
    return 31;
} else if (month == 7) {
    return 31;
} else if (month == 8) {
    return 30;
} else if (month == 9) {
    return 31;
} else if (month == 10) {
    return 30;
} else if (month == 11) {
    return 31;
return -1;
intgetDaysInMonth(int month, int year)
get Days In Month
int m = days_in_month[month - 1];
if (month == 2 && isLeapYear(year)) {
    m++;
return m;
intgetDaysInMonth(int monthNum)
get Days In Month
if (monthNum < 0) {
    throw new IllegalArgumentException("Month number must be non-negative");
if (monthNum >= 12) {
    throw new IndexOutOfBoundsException("There are 12 months in a year, so monthNum must be in 0..11");
return DOM[monthNum];