Java Day of minusDate(int day, int type)

Here you can find the source of minusDate(int day, int type)

Description

return Minus day to date strings with user defined format.

License

Open Source License

Parameter

Parameter Description
format string representation of the date format. For example, "yyyy-MM-dd".

Return

int

Declaration

public static String minusDate(int day, int type) 

Method Source Code

//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());
    }
}

Related

  1. isNowDay(String d)
  2. isSomeDay(String date)
  3. lastDays(int count)
  4. long2StringPerDay(long t, SimpleDateFormat sdf)
  5. minDayToLong(String time)
  6. nextDay(Date date)
  7. nowDayString()
  8. parseBirthday(String r)
  9. parseCalendarDayFormat(String strDate)