Android Day Add beforeNDays(Calendar c, int n)

Here you can find the source of beforeNDays(Calendar c, int n)

Description

before N Days

Declaration

public static Calendar beforeNDays(Calendar c, int n) 

Method Source Code

//package com.java2s;

import java.util.Calendar;

public class Main {
    public static Calendar beforeNDays(Calendar c, int n) {

        long offset = n * 24 * 60 * 60 * 1000;
        Calendar calendar = null;
        if (c != null) {
            calendar = c;//from   w ww  .  j  av a 2 s  .  c om
        } else {
            calendar = Calendar.getInstance();
        }

        calendar.setTimeInMillis(calendar.getTimeInMillis() - offset);
        return calendar;
    }
}

Related

  1. addDayOfMonth(Date date)
  2. addDayOfMonth(Date date, int difference)
  3. addDay(long dateTimeMillis)
  4. addDay(long dateTimeMillis)
  5. decrementOneDay(Time t)
  6. addDays(Date date, int days)