Java Today toDaysBeforeOrAfter(Date date, Integer days)

Here you can find the source of toDaysBeforeOrAfter(Date date, Integer days)

Description

to Days Before Or After

License

Apache License

Declaration

public static Date toDaysBeforeOrAfter(Date date, Integer days) 

Method Source Code

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

import java.util.*;

public class Main {

    public static Date toDaysBeforeOrAfter(Date date, Integer days) {
        return add(date, Calendar.DAY_OF_YEAR, days);
    }/* ww  w  .  j a  va  2 s  .c o  m*/

    private static Date add(Date date, int field, int value) {
        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(date.getTime());
        cal.add(field, value);
        return cal.getTime();
    }
}

Related

  1. todayAsXSDDateString()
  2. todayAtDayEnd()
  3. todayDate()
  4. todayMinute()
  5. todayPlusDays(int days)
  6. todaysDate(int style)
  7. todaySortedTimestamp()
  8. todayStart()
  9. todaysTime()