Java Day Add addDay(Date date, int dayAmount)

Here you can find the source of addDay(Date date, int dayAmount)

Description

add Day

License

Open Source License

Declaration

public static Date addDay(Date date, int dayAmount) 

Method Source Code


//package com.java2s;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main {

    public static Date addDay(Date date, int dayAmount) {
        if (date == null) {
            return null;
        }//from w ww. jav a  2s.c  om

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.add(Calendar.DATE, dayAmount);
        return calendar.getTime();
    }

    public static String getTime(Date date) {
        if (date == null) {
            return null;
        }

        SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
        return format.format(date);
    }
}

Related

  1. addDate(String date, SimpleDateFormat format, int dayCnt)
  2. addDate(String str, int field, int dayNum)
  3. addDay(Date d, int amount)
  4. addDay(Date date, int day)
  5. addDay(Date date, int day)
  6. addDay(Date date, int days)
  7. addDay(Date date, int n)
  8. addDay(Date date, int num)
  9. addDay(Date date, int num)