List of utility methods to do Month Day
Date | addMonthsAndDays(Date date, int months, int days) add Months And Days Calendar sysDate = new GregorianCalendar(); sysDate.setTime(date); sysDate.add(Calendar.MONTH, months); sysDate.add(Calendar.DAY_OF_MONTH, days); return sysDate.getTime(); |
void | addMonthToDayOfMonth(Calendar c, int dayOfMonth, int monthInterval) add Month To Day Of Month for (int i = 0; i < monthInterval; i++) { c.set(Calendar.DAY_OF_MONTH, 1); c.add(Calendar.DATE, 33); c.set(Calendar.DAY_OF_MONTH, dayOfMonth); if (c.get(Calendar.DAY_OF_MONTH) != dayOfMonth) { c.set(Calendar.DAY_OF_MONTH, 1); c.add(Calendar.DAY_OF_MONTH, -1); |
int | daysInMonth(GregorianCalendar c) Here get the number of days in particular month int[] daysInMonths = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; daysInMonths[1] += c.isLeapYear(c.get(GregorianCalendar.YEAR)) ? 1 : 0; return daysInMonths[c.get(GregorianCalendar.MONTH)]; |
Date | firstDayOfMonth(Date date) first Day Of Month Calendar c = Calendar.getInstance();
c.setTime(date);
c.set(Calendar.DAY_OF_MONTH, 1);
return c.getTime();
|
Date | firstDayOfMonth(Date date) first Day Of Month Calendar cal = calendar(date);
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.set(Calendar.HOUR, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();
|
String | firstMonthDay(String dateTime, int num) first Month Day try { Date date = dd.parse(dateTime); Calendar now = Calendar.getInstance(); now.setTime(date); int year = now.get(Calendar.YEAR); int month = now.get(Calendar.MONTH) - num; int day = now.get(Calendar.DAY_OF_MONTH); now.set(year, month, day); ... |
int | getActualMaximumDayOfMonth(final Date date) Return maximun number of days in month. Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
|
String | getCurMonthFirstDay() get Cur Month First Day Calendar cal = Calendar.getInstance(); Date d = new Date(); cal.setTime(d); cal.set(Calendar.DATE, 1); return dateFormat(cal.getTime()); |
int | getCurrentDayOfMonth() get Current Day Of Month Calendar c = new GregorianCalendar(); c.setTime(getCurrentDate()); return c.get(Calendar.DAY_OF_MONTH); |
String | getCurretnMonthFirstDay() get Curretn Month First Day String current = getCurrentStringDate(); return current.substring(0, 7) + "-01"; |