Here you can find the source of getOffsetDateToDate(Date pDate, int offset)
public static Date getOffsetDateToDate(Date pDate, int offset) throws Exception
//package com.java2s; //License from project: GNU General Public License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static Date getOffsetDateToDate(Date pDate, int offset) throws Exception { Calendar c = Calendar.getInstance(); Date ret = null;// ww w. jav a2 s .co m try { c.setTime(pDate); c.add(6, offset); ret = c.getTime(); } catch (Exception e) { } return ret; } public static Date getOffsetDateToDate(String strDate, int offset) throws Exception { SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd"); Date date = fmt.parse(strDate); return getOffsetDateToDate(date, offset); } }