Java Date Add addDate(Date date, int field, int add)

Here you can find the source of addDate(Date date, int field, int add)

Description

add Date

License

Apache License

Declaration

public static Calendar addDate(Date date, int field, int add) 

Method Source Code

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

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

public class Main {

    public static Calendar addDate(Date date, int field, int add) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);/* ww w . j a  va  2s  .com*/
        calendar.add(field, add);
        // switch (field) {
        // case Calendar.YEAR:
        // case Calendar.MONTH:
        // case Calendar.DAY_OF_MONTH:
        // case Calendar.HOUR_OF_DAY:
        // case Calendar.MINUTE:
        // case Calendar.SECOND:
        // case Calendar.MILLISECOND:
        // calendar.set(field, calendar.get(field)+1);
        // default:
        // break;
        // }
        return calendar;
    }
}

Related

  1. add(long date, int field, int amount)
  2. add30Minutes(Date date)
  3. addCertainTime(java.util.Date date, double hours)
  4. addDate(Date date, int add)
  5. addDate(Date date, int amount, int type)
  6. addDate(Date date, int k)
  7. addDate(Date date, int noOfDays)
  8. addDate(Date date, int years, int months, int days)
  9. addDate(Date date, String unit, int quantity)