List of utility methods to do Month Calculate
Calendar | alignMonth(Calendar timestamp) Aligns the time fields to the start of the month. timestamp.set(Calendar.DAY_OF_MONTH, 1);
return alignDay(timestamp);
|
long | beforeAMonth() before A Month Calendar cal = Calendar.getInstance(); Date currentDate = new Date(); cal.setTime(currentDate); cal.add(Calendar.MONTH, -1); Date date = cal.getTime(); return date.getTime(); |
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; ... |
int | currentMonth() current Month Calendar rightNow = Calendar.getInstance();
return rightNow.get(Calendar.MONTH);
|
List | divideIntoMonthlyIntervals(Date start, Date end) returns a list of monthly intervals for the first of each month the first entry in the list is the 1st of the month before start and the last entry is the 1st of the month after the end. List<Date> result = new ArrayList<Date>(); Calendar c = startOfMonth(start); result.add(c.getTime()); do { int mm = c.get(Calendar.MONTH); int yy = c.get(Calendar.YEAR); mm++; if (mm >= 12) { ... |
long | endOfLastMonth() end Of Last Month Calendar cal = Calendar.getInstance(); cal.set(Calendar.DAY_OF_MONTH, 1); cal.set(Calendar.HOUR_OF_DAY, 23); cal.set(Calendar.MINUTE, 59); cal.set(Calendar.SECOND, 59); cal.set(Calendar.MILLISECOND, 999); cal.add(Calendar.DATE, -1); Date date = cal.getTime(); ... |
int | getAgeInMonths(Date startDate, Date endDate) get Age In Months Calendar start = new GregorianCalendar(); start.setTime(startDate); int startMOY = start.get(Calendar.MONTH); int startYear = start.get(Calendar.YEAR); Calendar end = new GregorianCalendar(); end.setTime(endDate); int endMOY = end.get(Calendar.MONTH); int endYear = end.get(Calendar.YEAR); ... |
int | getAlphaMonth(String mon) get Alpha Month mon = mon.toLowerCase(); if (MONTHS.get(mon) != null) { return MONTHS.get(mon); return 0; |
Integer | getCurrentMonth() get Current Month return Calendar.getInstance().get(Calendar.MONTH) + 1;
|
int | getCurrentMonth() get Current Month return getCurrentDate().getMonth();
|