Android Calendar Add addDay(Calendar c, int days)

Here you can find the source of addDay(Calendar c, int days)

Description

add Day

Declaration

public static Date addDay(Calendar c, int days) 

Method Source Code

//package com.java2s;

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

public class Main {
    public static Date addDay(Calendar c, int days) {
        if (c == null)
            return null;
        c.add(Calendar.DAY_OF_MONTH, days);
        return c.getTime();
    }//  w ww  . ja  va  2  s.c  om

    public static Date addDay(Date date, int days) {
        Calendar c = getCalendar(date);
        if (c == null)
            return null;
        c.add(Calendar.DAY_OF_MONTH, days);
        return c.getTime();
    }

    public static Calendar getCalendar(Date date) {
        if (date == null)
            return null;
        Calendar c = new GregorianCalendar();
        c.setTime(date);
        return c;
    }
}

Related

  1. add(int field, long time, int val)
  2. addMonth(Calendar c, int months)
  3. after(Calendar c, long offset)
  4. afterNDays(Calendar c, int n)
  5. getDateAdd(Date date, int amount)