Java Date Before getBeforeOrAfterDateByDayNumber(int dayNumber)

Here you can find the source of getBeforeOrAfterDateByDayNumber(int dayNumber)

Description

get Before Or After Date By Day Number

License

Apache License

Declaration

public static Date getBeforeOrAfterDateByDayNumber(int dayNumber) 

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 getBeforeOrAfterDateByDayNumber(int dayNumber) {
        return getBeforeOrAfterDateByDayNumber(new Date(), dayNumber);
    }/*from   ww  w .j a v a  2s . c  om*/

    public static Date getBeforeOrAfterDateByDayNumber(Date date, int dayNumber) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.add(Calendar.DAY_OF_MONTH, dayNumber);
        return c.getTime();
    }
}

Related

  1. daysBefore(Date date1)
  2. getBefore(Date date)
  3. getBeforeDate(final int unit, final int period)
  4. getBeforeDate(String range)
  5. getBeforeHourByCurrentTime(Date now, int mount)
  6. getDateBefore(Date d, int day)
  7. getDateBefore(Date d, int day)
  8. getDateBefore(Date date, int days)
  9. getDateBefore(int offsetDay, String strFormat)