Here you can find the source of getFutrueDate(Date oldDate, int addDay)
public static Date getFutrueDate(Date oldDate, int addDay)
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; public class Main { /**//from w ww . j a va 2 s .c o m * yyyy-MM-dd */ static public final String FORMAT_DATE_ONLY = "yyyy-MM-dd"; public static Date getFutrueDate(Date oldDate, int addDay) { Calendar c = Calendar.getInstance(); c.setTime(oldDate); c.add(Calendar.DATE, addDay); return c.getTime(); } public static Date getFutrueDate(String oldDate, int addDay) { Calendar c = Calendar.getInstance(); c.setTime(parse(oldDate, FORMAT_DATE_ONLY)); c.add(Calendar.DATE, addDay); return c.getTime(); } public static Date parse(String str, String format) { try { SimpleDateFormat sf = new SimpleDateFormat(format); sf.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai")); return sf.parse(str); } catch (ParseException e) { e.printStackTrace(); return null; } } }