Here you can find the source of minusDate(int day, int type)
Parameter | Description |
---|---|
format | string representation of the date format. For example, "yyyy-MM-dd". |
public static String minusDate(int day, int type)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.GregorianCalendar; public class Main { /**// w w w. j av a 2s . co m * return Minus day to date strings with user defined format. * @param format string representation of the date format. For example, "yyyy-MM-dd". * @return int */ public static String minusDate(int day, int type) { GregorianCalendar cal = new GregorianCalendar(); SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd"); cal.add(Calendar.DAY_OF_MONTH, -1); cal.add(type, -day); return formatter.format(cal.getTime()); } }