Java Date Before getDayFormSomeDay(Date date, int n, boolean before)

Here you can find the source of getDayFormSomeDay(Date date, int n, boolean before)

Description

get Day Form Some Day

License

Apache License

Declaration

public static long getDayFormSomeDay(Date date, int n, boolean before) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Main {

    public static long getDayFormSomeDay(Date date, int n, boolean before) {
        Calendar cal = new GregorianCalendar();
        cal.setTime(date);//  w w  w. ja  v a 2 s  . c  o  m
        if (before) {
            cal.add(Calendar.DATE, -n);
        } else {
            cal.add(Calendar.DATE, n);
        }
        return cal.getTime().getTime();
    }
}

Related

  1. getDateBeforeTheDay(String day, int num)
  2. getDateBeforeToday(int num)
  3. getDateBeforTwelveMonth()
  4. getDateTimeAfterOfBeforeHour(Integer AfterOfBeforeHour)
  5. getDayBeforeOrAfter2(Date time, int days)
  6. getDistanceMonthOfTwoDate(Date before, Date after)
  7. getMinuteBefore(Date date, int minute)
  8. getMonth(Date time, int monthBefore, int monthAfter)
  9. getMonthBefore(Date currentDate, int numberMonthBefore)