Java Month of Year getPreviousDay(int year, int month, int day, int days)

Here you can find the source of getPreviousDay(int year, int month, int day, int days)

Description

get Previous Day

License

Open Source License

Declaration

public static int[] getPreviousDay(int year, int month, int day, int days) 

Method Source Code


//package com.java2s;
import java.util.Calendar;

public class Main {

    public static int[] getPreviousDay(int year, int month, int day, int days) {
        Calendar calendar = Calendar.getInstance();
        calendar.set(year, month - 1, day);

        long longDate = (calendar.getTime()).getTime() - (1000 * 60 * 60 * 24 * days);
        java.util.Date date = new java.util.Date(longDate);
        calendar.setTime(date);//from  w w  w  .j a  va 2s .c o m

        int[] rtn = new int[3];
        rtn[0] = calendar.get(Calendar.YEAR);
        rtn[1] = calendar.get(Calendar.MONTH) + 1;
        rtn[2] = calendar.get(Calendar.DATE);

        return rtn;
    }
}

Related

  1. getNextYearMonth(String yearMonth)
  2. getNrDaysOfMonth(int month, int year)
  3. getNumberOfDays(int year, int month)
  4. getOntologyURIBase(String defaultBase, boolean appendYear, boolean appendMonth, boolean appendDay)
  5. getPreviousDateStringByMonth(int months)
  6. getPrevMonth(String divisionDate, int day, String outputFormat)
  7. getPreYearMonth()
  8. getSecondsOfMonth(int year, int month)
  9. getStartAndEndOfMonth(int month, int year)