Here you can find the source of getTodayAdd(int year, int month, int day)
public static String getTodayAdd(int year, int month, int day)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.GregorianCalendar; public class Main { public static String getTodayAdd(int year, int month, int day) { String tmpstr = ""; GregorianCalendar calendar = new GregorianCalendar(); int yearnow = calendar.get(Calendar.YEAR) + year; int monthnow = calendar.get(Calendar.MONTH) + month; int daynow = calendar.get(Calendar.DAY_OF_MONTH) + day; tmpstr += yearnow + "-"; if (monthnow < 10) { tmpstr += "0" + monthnow + "-"; } else {//from w w w .j a v a 2 s.c o m tmpstr += monthnow + "-"; } if (daynow < 10) { tmpstr += "0" + daynow; } else { tmpstr += daynow; } return tmpstr; } }