List of utility methods to do Calendar Month
String | getFirstDayOfMonth(Calendar cal) get First Day Of Month return cal.get(Calendar.YEAR) + (cal.get(Calendar.MONTH) + 1) + "01"; |
Date | getFirstDayOfMonth(final Calendar calendar, final Date date) Get the first day of the input date's month calendar.setTime(date);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
calendar.set(Calendar.DAY_OF_MONTH, 1);
Date firstDayInMonth = calendar.getTime();
return firstDayInMonth;
...
|
int | getLastDateOfMonth(Calendar calendar) Returns the last date of the month represented by the passed cal
Calendar tmpCal = new GregorianCalendar(calendar.getTimeZone()); tmpCal.set(Calendar.YEAR, calendar.get(Calendar.YEAR)); tmpCal.set(Calendar.MONTH, calendar.get(Calendar.MONTH)); tmpCal.set(Calendar.DAY_OF_MONTH, 1); return tmpCal.getActualMaximum(Calendar.DAY_OF_MONTH); |
Calendar | getLastDayOfMonth(Calendar c) Gets the last day of the month based on the given Calendar . Calendar result = (Calendar) c.clone();
result.set(Calendar.DAY_OF_MONTH, 31);
result.set(Calendar.HOUR_OF_DAY, 0);
result.set(Calendar.MINUTE, 0);
result.set(Calendar.SECOND, 0);
result.set(Calendar.MILLISECOND, 0);
return result;
|
Date | getLastDayOfMonth(Calendar c) get Last Day Of Month int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH) + 1; int day = 1; if (month > 11) { month = 0; year = year + 1; c.set(year, month, day - 1, 0, 0, 0); ... |
Calendar | getLastDayOfMonth(Calendar calendar) get Last Day Of Month Calendar ret = (Calendar) calendar.clone();
ret.add(Calendar.MONTH, 1);
ret.set(Calendar.DAY_OF_MONTH, 0);
return ret;
|
int | getLastMonthDays(Calendar c) get Last Month Days Calendar calendar = c;
calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - 1);
return calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
|
String | getMonth(Calendar c) gets the 3 character month string from the given calendar return MONTHS[c.get(Calendar.MONTH)];
|
String | getMonth(Calendar cal) get Month return strLen(String.valueOf(cal.get(Calendar.MONTH) + 1), 2);
|
int | getMonth(Calendar calendar) get Month return calendar.get(Calendar.MONTH);
|