Here you can find the source of subtractDate(Date date, int type, Integer quantity)
public static Date subtractDate(Date date, int type, Integer quantity)
//package com.java2s; //License from project: Open Source License import java.util.Date; import java.util.Calendar; public class Main { private static int SUBTRACT = 1; public static Date subtractDate(Date date, int type, Integer quantity) { return manipulateDate(date, type, quantity, SUBTRACT); }// ww w . j a v a 2 s. c o m private static Date manipulateDate(Date date, int type, Integer quantity, int operation) { if (date == null) { throw new IllegalArgumentException("Sum/subtraction date should not be null"); } if (quantity < 0) { throw new IllegalArgumentException("Sum/subtraction should not receive a negative value"); } Calendar c = Calendar.getInstance(); c.setTime(date); if (operation == 0) { c.set(type, c.get(type) + quantity); } else { c.set(type, c.get(type) - quantity); } return c.getTime(); } }