Java Day Add addDate(String str, int field, int dayNum)

Here you can find the source of addDate(String str, int field, int dayNum)

Description

add Date

License

Apache License

Declaration

public static Date addDate(String str, int field, int dayNum) 

Method Source Code

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

import java.text.ParseException;
import java.text.SimpleDateFormat;

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

public class Main {
    public static Date addDate(String str, int field, int dayNum) {
        Date date = null;/*from   ww w  .j  a v a 2s  .  c  om*/
        SimpleDateFormat sdate = new SimpleDateFormat("yyyy-MM-dd");
        GregorianCalendar gc = new GregorianCalendar();
        try {
            date = (Date) sdate.parse(str);
            gc.setTime(date);
            gc.add(field, dayNum);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return gc.getTime();
    }
}

Related

  1. add(String date, int day)
  2. addDate(Date d, long day)
  3. addDate(Date date, int day)
  4. addDate(java.util.Date date, int day)
  5. addDate(String date, SimpleDateFormat format, int dayCnt)
  6. addDay(Date d, int amount)
  7. addDay(Date date, int day)
  8. addDay(Date date, int day)
  9. addDay(Date date, int dayAmount)