Here you can find the source of daysOfnumbe(Date sDate, int number)
public static Date daysOfnumbe(Date sDate, int number) throws ParseException
//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.GregorianCalendar; import java.util.SimpleTimeZone; public class Main { public static final String SHORT_TIME_FORMAT = "yyyy-MM-dd"; public static Date daysOfnumbe(Date sDate, int number) throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat(SHORT_TIME_FORMAT); Calendar c = Calendar.getInstance(); c.add(Calendar.DATE, number); return convertStringToDate(SHORT_TIME_FORMAT, sdf.format(c.getTime())); }//w w w . j a v a 2s.c om /** * This method generates a string representation of a date/time in the * format you specify on input * * @param aMask * the date pattern the string is in * @param strDate * a string representation of a date * @return a converted Date object * @throws ParseException * N/A * @see java.text.SimpleDateFormat */ public static Date convertStringToDate(String aMask, String strDate) { SimpleDateFormat df = new SimpleDateFormat(aMask); df.setCalendar(new GregorianCalendar(new SimpleTimeZone(0, "GMT"))); Date date = Calendar.getInstance().getTime(); try { date = df.parse(strDate); } catch (ParseException e) { e.printStackTrace(); } return (date); } }