Here you can find the source of dateAddDays(Date time, int days, String dateFormat)
public static String dateAddDays(Date time, int days, String dateFormat)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String dateAddDays(Date time, int days, String dateFormat) { SimpleDateFormat sdf = new SimpleDateFormat(dateFormat); long timeLong = time.getTime() / 1000 + 60l * 60 * 24 * days; time.setTime(timeLong * 1000);/*from w ww .j a va2 s . c o m*/ String timeStr = sdf.format(time); return timeStr; } public static String dateAddDays(Date time, int days, SimpleDateFormat dateFormat) { long timeLong = time.getTime() / 1000 + 60l * 60 * 24 * days; time.setTime(timeLong * 1000); String timeStr = dateFormat.format(time); return timeStr; } }