Here you can find the source of calculatorDate(int incrementYear, int incrementMonth, int incrementDay, int incrementHour, int incrementMin, int incrementSec)
public static Date calculatorDate(int incrementYear, int incrementMonth, int incrementDay, int incrementHour, int incrementMin, int incrementSec)
//package com.java2s; import java.util.*; public class Main { public static Date calculatorDate(int incrementYear, int incrementMonth, int incrementDay, int incrementHour, int incrementMin, int incrementSec) { Calendar c = Calendar.getInstance(); if (incrementYear != 0) { c.add(Calendar.YEAR, incrementYear); }//w ww. ja v a 2 s. c o m if (incrementMonth != 0) { c.add(Calendar.MONTH, incrementMonth); } if (incrementDay != 0) { c.add(Calendar.DAY_OF_MONTH, incrementDay); } if (incrementHour != 0) { c.add(Calendar.HOUR_OF_DAY, incrementHour); } if (incrementMin != 0) { c.add(Calendar.MINUTE, incrementMin); } if (incrementSec != 0) { c.add(Calendar.SECOND, incrementSec); } return c.getTime(); } public static Date calculatorDate(Date date, int incrementYear, int incrementMonth, int incrementDay, int incrementHour, int incrementMin, int incrementSec) { Calendar c = Calendar.getInstance(); c.setTime(date); if (incrementYear != 0) { c.add(Calendar.YEAR, incrementYear); } if (incrementMonth != 0) { c.add(Calendar.MONTH, incrementMonth); } if (incrementDay != 0) { c.add(Calendar.DAY_OF_MONTH, incrementDay); } if (incrementHour != 0) { c.add(Calendar.HOUR_OF_DAY, incrementHour); } if (incrementMin != 0) { c.add(Calendar.MINUTE, incrementMin); } if (incrementSec != 0) { c.add(Calendar.SECOND, incrementSec); } return c.getTime(); } }