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

StringaddDay(java.util.Date dt, long day)
add date
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
sdf.setTimeZone(getTimeZone());
return sdf.format(addDate(dt, day));
StringaddDay(String currentdate, int add_day)
add Day
GregorianCalendar gc = null;
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
int year, month, day;
try {
    year = Integer.parseInt(currentdate.substring(0, 4));
    month = Integer.parseInt(currentdate.substring(5, 7)) - 1;
    day = Integer.parseInt(currentdate.substring(8, 10));
    gc = new GregorianCalendar(year, month, day);
...
DateaddDay(String d)
add Day
SimpleDateFormat sd = new SimpleDateFormat(DATE_FORMAT);
Date daten = null;
try {
    daten = sd.parse(d);
} catch (ParseException e) {
    e.printStackTrace();
Calendar c = Calendar.getInstance();
...
StringaddDay(String data)
add Day
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar cd = Calendar.getInstance();
try {
    cd.setTime(sdf.parse(data));
    cd.add(5, 1);
} catch (ParseException e) {
    e.printStackTrace();
return sdf.format(cd.getTime());
DateaddDay(String datetime, int day)
add Day
Calendar cal = Calendar.getInstance();
cal.setTime(parseDate(datetime));
cal.add(Calendar.DAY_OF_YEAR, day);
return cal.getTime();
longaddDayInterval(long millis, int dayInterval)
addDayInterval
Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("GMT")); 
calendar.setTimeInMillis(millis);
calendar.add(Calendar.DAY_OF_MONTH, dayInterval);
return calendar.getTimeInMillis();
DateaddDays(Date aDate, int days)
Add days to a date by value.
return addTime(aDate, (24 * days), Calendar.HOUR);
DateaddDays(Date baseDate, int amount, boolean endOfDay)
Adds the specified number of days to the stated.
Calendar cal = Calendar.getInstance();
synchronized (cal) {
    cal.setTime(baseDate);
    cal.add(Calendar.DATE, amount);
if (endOfDay) {
    return endOfDay(cal.getTime());
return cal.getTime();
DateaddDays(Date beginDate, int days)
add Days
return changeTime(Calendar.DAY_OF_YEAR, beginDate, days);
DateaddDays(Date d, double count)
add count days days is truncated to second and can be negative
if (d == null) {
    return null;
int sec = (int) (count * 3600 * 24);
int sign = 1;
if (sec < 0) {
    sec = -sec;
    sign = -1;
...