Android Date Add addWeeks(Date date, int amount)

Here you can find the source of addWeeks(Date date, int amount)

Description

add Weeks

Declaration

public static Timestamp addWeeks(Date date, int amount) 

Method Source Code

//package com.java2s;

import java.sql.Timestamp;

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

public class Main {
    public static Timestamp addWeeks(Date date, int amount) {
        return add(date, Calendar.WEEK_OF_YEAR, amount);
    }/*w  w w  . j  a  va  2s  . c  o m*/

    public static Timestamp add(Date date, int calendarField, int amount) {
        if (date == null) {
            throw new IllegalArgumentException("The date must not be null");
        }
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.add(calendarField, amount);
        return new Timestamp(c.getTimeInMillis());
    }
}

Related

  1. addMonths(Date date, int amount)
  2. addMonths(Date date, int amount)
  3. addMonthsToDate(Date date, int monthsToBeAdded)
  4. addSeconds(Date date, int amount)
  5. addSeconds(Date date, int amount)
  6. addWeeks(Date date, int amount)
  7. addYearToDate(Date date, int yearsToBeAdded)
  8. addYears(Date date, int amount)
  9. addYears(Date date, int amount)