Here you can find the source of add(int date, int days)
public static String add(int date, int days)
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static Date add(int days) { Calendar now = Calendar.getInstance(); now.add(Calendar.DAY_OF_YEAR, days); return now.getTime(); }/*from w w w.j av a 2 s . co m*/ public static String add(int days, String pattern) { Date date = add(days); SimpleDateFormat format = new SimpleDateFormat(pattern); return format.format(date); } public static String add(int date, int days) { try { SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); Calendar cd = Calendar.getInstance(); cd.setTime(format.parse(String.valueOf(date))); cd.add(Calendar.DAY_OF_YEAR, days); return format.format(cd.getTime()); } catch (ParseException e) { throw new RuntimeException(e); } } public static String add(String date, int days, String pattern) { try { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Calendar cd = Calendar.getInstance(); cd.setTime(format.parse(date)); cd.add(Calendar.DAY_OF_YEAR, days); return new SimpleDateFormat(pattern).format(cd.getTime()); } catch (ParseException e) { throw new RuntimeException(e); } } }