Here you can find the source of todaySubtract(String years, String months)
public final static String todaySubtract(String years, String months)
//package com.java2s; /**/*from ww w . j a v a 2 s .c o m*/ * @copyright Copyright (C) 2014-2015 City of Bloomington, Indiana. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.txt * @author W. Sibo <sibow@bloomington.in.gov> */ import java.util.*; public class Main { public final static String todaySubtract(String years, String months) { Calendar cal = Calendar.getInstance(); int yy = 0, mm = 0, dd = 0; try { if (years != null && !years.equals("0")) { yy = Integer.parseInt(years); } if (months != null && !months.equals("0")) { mm = Integer.parseInt(months); } mm = mm + yy * 12; // total months cal.add(Calendar.MONTH, -mm); } catch (Exception ex) { System.err.println(ex); } mm = cal.get(Calendar.MONTH) + 1; dd = cal.get(Calendar.DATE); yy = cal.get(Calendar.YEAR); return "" + mm + "/" + dd + "/" + yy; } }