Java Utililty Methods Month of Year

List of utility methods to do Month of Year

Description

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

Method

intgetLastMonthOfQuater(Date date)
get Last Month Of Quater
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
Date lastDayOfQuarter = getLastDayOfQuarter(calendar.get(Calendar.YEAR), getQuarterOfYear(date));
int quarter = getQuarterOfYear(date);
calendar.setTime(lastDayOfQuarter);
int i = calendar.get(Calendar.MONTH) + 1;
return i;
intgetLastMonthOfYear()
get Last Month Of Year
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MONTH, 0);
int lastmonth = cal.get(Calendar.MONTH);
return lastmonth;
intgetMaxDayOfMonth(int year, int month)
get Max Day Of Month
if (month == 1 && isLeapYear(year)) {
    return 29;
return DAY_OF_MONTH[month];
intgetMonth(int week, int year)
Gets the month.
Calendar cal = getFirstSundayDateInYear(year);
cal.add(Calendar.DAY_OF_YEAR, (week - 1) * 7);
return cal.get(Calendar.MONTH);
intgetMonthDays(Object year, Object month)
get Month Days
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, Integer.parseInt(year.toString()));
cal.set(Calendar.MONTH, Integer.parseInt((month.toString())) - 1);
return cal.getActualMaximum(Calendar.DAY_OF_MONTH);
intgetMonthHaveDays(int year, int month)
get Month Have Days
Calendar cal = Calendar.getInstance();
cal.set(year, month - 1, 1);
return cal.getActualMaximum(Calendar.DATE);
StringgetMonthOfYear(int m)
get Month Of Year
if (m == 0) {
    return "Jan";
} else if (m == 1) {
    return "Feb";
} else if (m == 2) {
    return "Mar";
} else if (m == 3) {
    return "Apr";
...
intgetMonthOfYear(long time)
get Month Of Year
return (int) (getTotalMonths(time) % monthsInYear);
intgetMonthOfYearFromTimestamp(long ms)
get Month Of Year From Timestamp
if (ms < 0)
    throw new NumberFormatException("argument must be positive");
Calendar cal = Calendar.getInstance(TIMEZONE, LOCALE);
cal.setTimeInMillis(ms);
return cal.get(Calendar.MONTH);
DategetMonthStart(int year, int month)
Get the beginning time of a month
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, month);
cal.set(Calendar.DATE, 1);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
return cal.getTime();
...