Java Utililty Methods Month Add

List of utility methods to do Month Add

Description

The list of methods to do Month Add are organized into topic(s).

Method

StringaddMonthTimetamp(long lTimeStamp, String _pattern, int month)
add Month Timetamp
Date date = new Date(lTimeStamp);
Calendar cal = Calendar.getInstance();
cal.setTime(date);
int y = cal.get(Calendar.YEAR);
int m = cal.get(Calendar.MONTH);
int d = cal.get(Calendar.DATE);
cal.set(y, m + month, d);
Date addMonth = cal.getTime();
...
DategetEndOfMonth(Date currentDate)
get End Of Month
Calendar cal = Calendar.getInstance();
cal.setTime(currentDate);
cal.set(Calendar.DATE, cal.getActualMaximum(Calendar.DATE));
return cal.getTime();
DategetEndOfMonth(Date date)
get End Of Month
final GregorianCalendar utcCalendar = createUtcCalendar(date);
final int maxDay = utcCalendar.getActualMaximum(Calendar.DAY_OF_MONTH);
utcCalendar.set(Calendar.DAY_OF_MONTH, maxDay);
return getEndOfDay(utcCalendar.getTime());
longgetEndOfMonth(long date)
Returns the date corresponding to the end of the month.
return getMonth(date, 1);
StringmonthAdd(final String strDate, final int month)
month Add
final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date date;
try {
    date = simpleDateFormat.parse(strDate);
    final Calendar calender = Calendar.getInstance();
    calender.setTime(date);
    calender.add(Calendar.MONTH, month);
    return simpleDateFormat.format(calender.getTime());
...