Java Day Add addDays(Date date, int days)

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

Description

add Days

License

Apache License

Declaration

public static Date addDays(Date date, int days) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

public class Main {
    public static Date addDays(Date date, int days) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);/*from w  ww .  jav  a 2  s. c om*/
        calendar.add(Calendar.DAY_OF_MONTH, days);
        return calendar.getTime();
    }

    public static Date getTime(int hour, int minutes) {
        return getTime(hour, minutes, true);
    }

    public static Date getTime(int hour, int minutes, Boolean is24Hour) {
        Calendar calendar = Calendar.getInstance();
        calendar.set(is24Hour ? Calendar.HOUR_OF_DAY : Calendar.HOUR, hour);
        calendar.set(Calendar.MINUTE, minutes);
        calendar.set(Calendar.SECOND, 0);
        return calendar.getTime();
    }
}

Related

  1. addDays(Date d, int n)
  2. addDays(Date date, int amount)
  3. addDays(Date date, int count)
  4. addDays(Date date, int day)
  5. addDays(Date date, int days)
  6. addDays(Date date, int days)
  7. addDays(Date date, int days)
  8. addDays(Date date, int days)
  9. addDays(Date date, int days)