Here you can find the source of addDate(String str, int field, int dayNum)
public static Date addDate(String str, int field, int dayNum)
//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(); } }