Java Day Add addDay(int days)

Here you can find the source of addDay(int days)

Description

add Day

License

Open Source License

Declaration

public static Date addDay(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 addDay(Date date, int days) {
        if (date == null) {
            return null;
        }/*from w w  w . j  ava  2 s  .  c o m*/
        GregorianCalendar calendar = new GregorianCalendar();
        calendar.setTime(date);
        calendar.add(Calendar.DATE, days);
        return calendar.getTime();
    }

    public static Date addDay(int days) {
        return addDay(new Date(), days);
    }

    public static Date setTime(Date date, int hours, int minutes, int seconds) {
        Calendar calendar = new GregorianCalendar();
        calendar.setTime(date);
        calendar.set(Calendar.HOUR_OF_DAY, hours);
        calendar.set(Calendar.MINUTE, minutes);
        calendar.set(Calendar.SECOND, seconds);
        date = calendar.getTime();
        return date;
    }
}

Related

  1. addDay(Date date, int n)
  2. addDay(Date date, int num)
  3. addDay(Date date, int num)
  4. addDay(Date date, String pattern, int num)
  5. addDay(Date oriDate, int amount)
  6. addDay(int k)
  7. addDay(java.util.Date date)
  8. addDay(java.util.Date dt, long day)
  9. addDay(String currentdate, int add_day)