Java Date Before getPreviousDate(String before)

Here you can find the source of getPreviousDate(String before)

Description

This method gets the past dates based on the no.

License

Open Source License

Parameter

Parameter Description
before the before

Return

the previous date

Declaration

public static Calendar getPreviousDate(String before) 

Method Source Code

//package com.java2s;

import java.util.Calendar;

public class Main {
    /**/*w w  w .  j av  a  2s  .c  o  m*/
     * This method gets the past dates based on the no. of days passed.
     * 
     * @param before
     *            the before
     * @return the previous date
     */
    public static Calendar getPreviousDate(String before) {

        int beforeInt = 0 - Integer.valueOf(before);
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DATE, beforeInt);
        return cal;
    }
}

Related

  1. getMonth(Date time, int monthBefore, int monthAfter)
  2. getMonthBefore(Date currentDate, int numberMonthBefore)
  3. getMonthStartDateBeforeCurrent(int monthNum, Date current)
  4. getOneHourBefore(Date date)
  5. getPassedMonthBetweenDate(Date before, Date after)
  6. getQuarterStartDateBeforeCurrent(int num, Date current)
  7. getSomeDaysBeforeAfter(Date date, int days)
  8. isAtLeastOneDayBefore(Date daybefore, Date dayafter)
  9. isBefore(Date date)