Java Utililty Methods Day Add

List of utility methods to do Day Add

Description

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

Method

StringaddDays(String startDate, int amount)
add Days
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar cal = Calendar.getInstance();
cal.setTime(sdf.parse(startDate));
cal.add(Calendar.DAY_OF_MONTH, amount);
long mills = cal.getTimeInMillis();
Date date = new Date(mills);
return sdf.format(date);
DateaddDays2Date(Date d, int days)
add Days Date
calendar.clear();
calendar.setTime(d);
calendar.add(Calendar.DAY_OF_MONTH, days);
return calendar.getTime();
DateaddDays2Date(String str, int days)
add Days Date
SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd");
Date date = fmt.parse(str);
date.setTime(date.getTime() + (long) days * 1000L * 60L * 60L * 24L);
return date;
StringaddDaysByFormatter(int days, String dateFormat)
get specified time string in specified date format.
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.DATE, days);
SimpleDateFormat formatter = new SimpleDateFormat(dateFormat);
return formatter.format(cal.getTime());
java.util.DateaddDaysDate(final java.util.Date date1, final int nbdays)
add Days Date
if (date1 == null) {
    return null;
final GregorianCalendar cal = new GregorianCalendar();
cal.setTime(date1);
cal.add(Calendar.DATE, nbdays);
return cal.getTime();
DateaddDaysOnDate(final Date date, final int numberOfDays)
Adds days on Date.
Date addedDate = null;
if (date != null) {
    final Calendar calendar = new GregorianCalendar();
    calendar.setTime(date);
    calendar.add(Calendar.DATE, numberOfDays);
    addedDate = calendar.getTime();
return addedDate;
...
DateaddDaysToDate(Date date, int numDays)
add Days To Date
Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(Calendar.DATE, numDays);
return c.getTime();
DateaddDaysToDate(Date date, int value)
Adds value days to date.
Calendar calendar = getCalendar(date);
calendar.add(Calendar.DATE, value);
return calendar.getTime();
DateaddDaysToDate(final Date d, final int days)
Adds days to a Date.
Calendar cal = getStockExchangeCalendar();
cal.setTime(d);
cal.add(Calendar.DAY_OF_MONTH, days);
return cal.getTime();
DateaddDaysToDate(String s, int day, String format)
return add day to date object with user defined format.
Date date = check(s, format);
return addDaysToDate(date, day);