List of utility methods to do Calendar Month
int | calendarMonthToInt(int calendarMonth) calendar Month To Int if (calendarMonth == Calendar.JANUARY) { return 1; } else if (calendarMonth == Calendar.FEBRUARY) { return 2; } else if (calendarMonth == Calendar.MARCH) { return 3; } else if (calendarMonth == Calendar.APRIL) { return 4; ... |
void | calToLastDayOfMonth(Calendar c) cal To Last Day Of Month int day = lastDayOfMonth(c);
c.set(Calendar.DATE, day);
|
Calendar | convertRemoveAfterMonth(Calendar cal) convert Remove After Month Calendar outCal = Calendar.getInstance();
outCal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), 1, 0, 0, 0);
return outCal;
|
void | endOfMonth(Calendar calendar) Adjusts the calendar to the end of the current month. calendar.add(Calendar.MONTH, 1); startOfMonth(calendar); calendar.add(Calendar.MILLISECOND, -1); |
void | floorDayOfMonth(Calendar cal) floor Day Of Month cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH)); |
int | getCalDayofMonth(Date calendarDay) This method is used for getting calendar date of month Calendar calendar = Calendar.getInstance();
calendar.setTime(calendarDay);
return calendar.get(Calendar.DAY_OF_MONTH);
|
String | getDayOfMonthPostfix(Calendar cal) get Day Of Month Postfix String postfix = "th"; switch (cal.get(Calendar.DAY_OF_MONTH)) { case 1: case 21: case 31: postfix = "st"; break; case 2: ... |
int | getDaysInMonth(Calendar cal) get Days In Month return getDaysInMonth(cal.get(Calendar.MONTH), cal.get(Calendar.YEAR));
|
Date | getFirstDateOfMonth(Calendar calendar) get First Date Of Month calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
return calendar.getTime();
|
Date | getFirstDayOfMonth(Calendar c) get First Day Of Month int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH); int day = 1; c.set(year, month, day, 0, 0, 0); return c.getTime(); |