Java Day Add addDays(Date date, int days)

Here you can find the source of addDays(Date date, int days)

Description

add Days

License

Open Source License

Declaration

public static Date addDays(Date date, int days) 

Method Source Code

//package com.java2s;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Main {
    public static Date addDays(Date date, int days) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);// ww w  .  ja  v  a2  s  . c o  m
        cal.add(Calendar.DATE, days); //minus number would decrement the days
        return cal.getTime();
    }

    public static Date setTime(final Date date, final int hourOfDay, final int minute, final int second) {
        final GregorianCalendar gc = new GregorianCalendar();
        gc.setTime(date);
        gc.set(Calendar.HOUR_OF_DAY, hourOfDay);
        gc.set(Calendar.MINUTE, minute);
        gc.set(Calendar.SECOND, second);
        return gc.getTime();
    }
}

Related

  1. addDays(Date date, int day)
  2. addDays(Date date, int days)
  3. addDays(Date date, int days)
  4. addDays(Date date, int days)
  5. addDays(Date date, int days)
  6. addDays(Date date, int days)
  7. addDays(Date date, int daysOffset, boolean stripTime)
  8. addDays(Date date, int daysToAdd)
  9. addDays(Date date, int i)