Java Date Before getDateBeforeOrAfter(int iDate)

Here you can find the source of getDateBeforeOrAfter(int iDate)

Description

get Date Before Or After

License

Apache License

Declaration

public static Date getDateBeforeOrAfter(int iDate) 

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 getDateBeforeOrAfter(int iDate) {
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DAY_OF_MONTH, iDate);
        return cal.getTime();
    }/*from   w  w  w .j  av a2  s.  c  o  m*/

    public static Date getDateBeforeOrAfter(Date curDate, int iDate) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(curDate);
        cal.add(Calendar.DAY_OF_MONTH, iDate);
        return cal.getTime();
    }
}

Related

  1. getDateBefore(int offsetDay, String strFormat)
  2. getDateBefore(int year, int month, int day)
  3. getDateBefore(String d, int day)
  4. getDateBeforeHours(Date date, int hours)
  5. getDateBeforeNextMonth(Date date, Integer month, Integer day)
  6. getDateBeforeOrAfterV2(int idx)
  7. getDateBeforeSomeMinutes(int minute, long timestamp)
  8. getDateBeforeTheDay(String day, int num)
  9. getDateBeforeToday(int num)