List of utility methods to do Month Calculate
int | intToCalendarMonth(int month) int To Calendar Month if (month == 1) { return Calendar.JANUARY; } else if (month == 2) { return Calendar.FEBRUARY; } else if (month == 3) { return Calendar.MARCH; } else if (month == 4) { return Calendar.APRIL; ... |
boolean | isFirstOfMonth(long date) is First Of Month boolean ret = false; Calendar calendar = CALENDAR; synchronized (calendar) { calendar.setTimeInMillis(date); int currentMonth = calendar.get(Calendar.MONTH); calendar.add(Calendar.DATE, -1); int yesterdayMonth = calendar.get(Calendar.MONTH); ret = (currentMonth != yesterdayMonth); ... |
boolean | isMonthEnd(Date date) is Month End Calendar cal = Calendar.getInstance(); cal.setTime(date); if (cal.get(Calendar.DATE) == cal.getActualMaximum(Calendar.DAY_OF_MONTH)) return true; else return false; |
boolean | isSameMonth(final Calendar c1, final Calendar c2) is Same Month return c1.get(Calendar.MONTH) == c2.get(Calendar.MONTH);
|
int | monthsBetween(String pFormerStr, String pLatterStr) months Between GregorianCalendar vFormer = parse2Cal(pFormerStr);
GregorianCalendar vLatter = parse2Cal(pLatterStr);
return monthsBetween(vFormer, vLatter);
|
Date | nextMonth(Date date, int months) next Month Calendar cal = Calendar.getInstance(); if (date != null) { cal.setTime(date); cal.add(Calendar.MONTH, months); return cal.getTime(); |
Date | nextMonths(int diff) next Months return add(new Date(), Calendar.MONTH, diff); |
Calendar | startOfMonth(Date d) start Of Month Calendar c = new GregorianCalendar(); c.setTime(d); int yy = c.get(Calendar.YEAR); int mm = c.get(Calendar.MONTH); c = new GregorianCalendar(yy, mm, 1); return c; |
Date | startOfMonth(Date date) start Of Month if (date == null) { return null; Calendar cal = new GregorianCalendar(); cal.setTime(date); cal.set(Calendar.DAY_OF_MONTH, 1); return cal.getTime(); |
Date | startOfMonthDate(Date date) start Of Month Date Calendar now = Calendar.getInstance();
now.setTime(date);
now.set(Calendar.DAY_OF_MONTH, 1);
now.set(Calendar.HOUR_OF_DAY, 0);
now.set(Calendar.MINUTE, 0);
now.set(Calendar.SECOND, 0);
now.set(Calendar.MILLISECOND, 0);
return now.getTime();
...
|