Here you can find the source of addDate(Date date, int k)
public static String addDate(Date date, int k)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static String addDate(Date date, int k) { java.util.Calendar cal = Calendar.getInstance(); cal.setTime(date);/*from w ww .ja va2s .c o m*/ cal.add(Calendar.DATE, k); return format(cal.getTime()); } public static String format(Date date, String pattern) { if (date == null) { return null; } SimpleDateFormat sf = new SimpleDateFormat(pattern); return sf.format(date); } public static String format(Date date) { return format(date, "yyyy-MM-dd"); } }