List of utility methods to do Date to Month
Date | getNextMonthExtention(Date dt, Long n) get Next Month Extention Calendar cal = new GregorianCalendar(); cal.setTime(dt); Calendar firstCal = new GregorianCalendar(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + n.intValue(), 1); if (firstCal.getActualMaximum(Calendar.DAY_OF_MONTH) < cal.get(Calendar.DAY_OF_MONTH)) { return new GregorianCalendar(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + n.intValue() + 1, 1) .getTime(); } else { ... |
Date | getNextMonthFirstDate(Date date) get Next Month First Date Date tmpdate = getMonthFirstDate(date); cal.setTime(tmpdate); cal.add(Calendar.MONTH, 1); return new Date(cal.getTime().getTime()); |
Date | getNextMonthFirstDay(Date date) get Next Month First Day Calendar a = Calendar.getInstance();
a.setTime(date);
a.add(Calendar.MONTH, 1);
a.set(Calendar.DAY_OF_MONTH, 1);
a.set(Calendar.HOUR_OF_DAY, 0);
a.set(Calendar.MINUTE, 0);
a.set(Calendar.SECOND, 0);
return a.getTime();
...
|
Date | getNextMonthPreviousDay(Date date, int month_num) get Next Month Previous Day Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(Calendar.MONTH, month_num);
c.add(Calendar.DAY_OF_MONTH, -1);
return c.getTime();
|
Date | getNextMonthsByStartDate(Date date, int month) get Next Months By Start Date GregorianCalendar calendar = new GregorianCalendar(); 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.add(Calendar.MONTH, month); return calendar.getTime(); ... |
int | month(Date date) month return toCalendar(date).get(Calendar.MONTH) + 1;
|
int | month(Date inDate, TimeZone timeZone) Calcuate the month number (0 - 11) for the given date. Calendar calendar = Calendar.getInstance();
calendar.setTimeZone(timeZone);
calendar.setTime(inDate);
return calendar.get(Calendar.MONTH);
|
int | month(final Date date) Returns the month from the day, i.e. return fromDateToCalendar(date).get(MONTH) + 1;
|
Date | monthBegin(final Date date) month Begin Calendar c = Calendar.getInstance();
c.setTime(date);
c.set(Calendar.DAY_OF_MONTH, 1);
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
return c.getTime();
...
|
int | monthOf(Date date) Dates Extracts the month of the given Date starting at 1 (January=1, February=2, ...). return toCalendar(date).get(Calendar.MONTH) + 1;
|