Here you can find the source of getDate(String theDateStr, int days)
public static String getDate(String theDateStr, int days)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static String getDate(String theDateStr, int days) { Date theDate = java.sql.Date.valueOf(theDateStr); Calendar c = new GregorianCalendar(); c.setTime(theDate);/* ww w . j a v a 2 s. co m*/ c.add(GregorianCalendar.DATE, days); java.sql.Date d = new java.sql.Date(c.getTime().getTime()); return d.toString(); } public static Date getDate(Date theDate, int days) { Calendar c = new GregorianCalendar(); c.setTime(theDate); c.add(GregorianCalendar.DATE, days); return new Date(c.getTime().getTime()); } public static Date getDate(Date theDate, int field, int amount) { Calendar c = new GregorianCalendar(); c.setTime(theDate); c.add(field, amount); return new Date(c.getTime().getTime()); } public static String getTime(Date dt, String format) { SimpleDateFormat st = new SimpleDateFormat(format); return st.format(dt); } }