Here you can find the source of formatAddDate(String src, String pattern, int amount)
public static String formatAddDate(String src, String pattern, int amount) throws ParseException
//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 final SimpleDateFormat date_sdf = new SimpleDateFormat("yyyy-MM-dd"); public static String formatAddDate(String src, String pattern, int amount) throws ParseException { Calendar cal;/* www .j av a 2 s .c om*/ cal = parseCalendar(src, pattern); cal.add(Calendar.DATE, amount); return formatDate(cal); } public static Calendar parseCalendar(String src, String pattern) throws ParseException { Date date = parseDate(src, pattern); Calendar cal = Calendar.getInstance(); cal.setTime(date); return cal; } public static String formatDate() { return date_sdf.format(getCalendar().getTime()); } public static String formatDate(Calendar cal) { return date_sdf.format(cal.getTime()); } public static String formatDate(Date date) { return date_sdf.format(date); } public static String formatDate(long millis) { return date_sdf.format(new Date(millis)); } public static String formatDate(String pattern) { return getSDFormat(pattern).format(getCalendar().getTime()); } public static String formatDate(Calendar cal, String pattern) { return getSDFormat(pattern).format(cal.getTime()); } public static String formatDate(Date date, String pattern) { return getSDFormat(pattern).format(date); } public static Date parseDate(String src, String pattern) throws ParseException { return getSDFormat(pattern).parse(src); } public static Calendar getCalendar() { return Calendar.getInstance(); } public static Calendar getCalendar(long millis) { Calendar cal = Calendar.getInstance(); cal.setTime(new Date(millis)); return cal; } private static SimpleDateFormat getSDFormat(String pattern) { return new SimpleDateFormat(pattern); } }