Here you can find the source of getOffsetDateInFormat(int offsetDay, String pattern)
public static String getOffsetDateInFormat(int offsetDay, String pattern)
//package com.java2s; //License from project: Open Source License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.*; public class Main { public static String getOffsetDateInFormat(int offsetDay, String pattern) { DateFormat dateFormat = new SimpleDateFormat(pattern); Calendar cal = Calendar.getInstance(); if (offsetDay != 0) { cal.add(Calendar.DATE, offsetDay); }// w ww. j a va2 s .c o m return dateFormat.format(cal.getTime()); } }