Java Date Previous getPreviousDay(Date inputDate)

Here you can find the source of getPreviousDay(Date inputDate)

Description

get Previous Day

License

Open Source License

Declaration

public static Date getPreviousDay(Date inputDate) 

Method Source Code


//package com.java2s;

import java.util.Calendar;
import java.util.Date;

public class Main {
    public static Date getPreviousDay() {

        Calendar calendar = Calendar.getInstance();

        calendar.add(Calendar.DAY_OF_MONTH, -1);

        return calendar.getTime();
    }/* w  w w.j  a va  2  s.  c om*/

    public static Date getPreviousDay(Date inputDate) {

        Calendar calendar = getCalendar(inputDate);

        calendar.add(Calendar.DAY_OF_MONTH, -1);

        return calendar.getTime();
    }

    public static Calendar getCalendar(Date inputDate) {

        if (inputDate == null)
            return null;

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(inputDate);

        return calendar;
    }
}

Related

  1. getPreviousDate(final Date date)
  2. getPreviousDate(int period)
  3. getPreviousDateStart()
  4. getPreviousDay(Date date)
  5. getPreviousDay(Date dateTime)
  6. getPreviousFriday(final Date d)
  7. getPreviousMonday(Date day)
  8. getPreviousMonth(Date time)
  9. getPreviousMonth(long date)