Here you can find the source of getIntervalDate(String date, int intervalDays)
public static synchronized String getIntervalDate(String date, int intervalDays)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); public static synchronized String getIntervalDate(String date, int intervalDays) { Calendar cal = Calendar.getInstance(); int year = Integer.parseInt(String.valueOf(date).substring(0, 4)); int month = Integer.parseInt(String.valueOf(date).substring(4, 6)); int day = Integer.parseInt(String.valueOf(date).substring(6, 8)); cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, month - 1); cal.set(Calendar.DAY_OF_MONTH, day); cal.add(Calendar.DATE, intervalDays); return dateFormat.format(new Date(cal.getTimeInMillis())); }//from w w w . ja v a2 s. c o m }