Here you can find the source of addDays(String startDate, int amount)
public static String addDays(String startDate, int amount) throws Exception
//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 addDays(String startDate, int amount) throws Exception { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar cal = Calendar.getInstance(); cal.setTime(sdf.parse(startDate)); cal.add(Calendar.DAY_OF_MONTH, amount); long mills = cal.getTimeInMillis(); Date date = new Date(mills); return sdf.format(date); }//from w w w . j a va2 s. c o m public static String addDays(int amount) throws Exception { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar cal = Calendar.getInstance(); cal.add(Calendar.DAY_OF_MONTH, amount); long mills = cal.getTimeInMillis(); Date date = new Date(mills); return sdf.format(date); } }