Java Day Add addDay(Date date, int num)

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

Description

add Day

License

Apache License

Declaration

public static Date addDay(Date date, int num) 

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 addDay(Date date, int num) {
        Calendar startDT = Calendar.getInstance();
        startDT.setTime(date);/*from w w w . ja  va 2s. c  om*/
        startDT.add(Calendar.DAY_OF_MONTH, num);
        return startDT.getTime();
    }

    public static Integer addDay(Integer time, int day) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(Long.valueOf(time + "000"));
        calendar.add(Calendar.HOUR_OF_DAY, day * 24);
        return Integer.valueOf(String.valueOf(calendar.getTimeInMillis()).substring(0, 10));
    }
}

Related

  1. addDay(Date date, int day)
  2. addDay(Date date, int day)
  3. addDay(Date date, int dayAmount)
  4. addDay(Date date, int days)
  5. addDay(Date date, int n)
  6. addDay(Date date, int num)
  7. addDay(Date date, String pattern, int num)
  8. addDay(Date oriDate, int amount)
  9. addDay(int days)