List of utility methods to do Date Previous
Date | getPreDay(Date date) get Pre Day Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(Calendar.DATE, -1);
return c.getTime();
|
Date | getPrefixStartDate(Integer day) get Prefix Start Date Date date = new Date(); if (day == null) { return date; Calendar cal = Calendar.getInstance(); cal.add(Calendar.DAY_OF_MONTH, -day); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); ... |
Date | GetPreMonthBeginDate() Get Pre Month Begin Date Calendar c = Calendar.getInstance();
c.add(Calendar.MONTH, -1);
c.set(Calendar.DAY_OF_MONTH, c.getActualMinimum(Calendar.DAY_OF_MONTH));
return c.getTime();
|
Date | getPreMonthDate(Date date, int month) get the previos n month Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) - month, calendar.get(Calendar.DATE),
0,
0,
0);
calendar.clear(Calendar.MILLISECOND);
return calendar.getTime();
...
|
Date | getPrevDay(Date date) get Prev Day if (date == null) { throw new NullPointerException(); Calendar calendar = new GregorianCalendar(); calendar.setTime(date); calendar.add(Calendar.DAY_OF_YEAR, -1); return calendar.getTime(); |
Date | getPrevDueDate(int payperiod, long time) get Prev Due Date Calendar now = Calendar.getInstance(); now.setTimeInMillis(time); if (payperiod == 1) { now.add(Calendar.MONTH, -1); } else if (payperiod == 2) { now.add(Calendar.MONTH, -3); } else if (payperiod == 3) { now.add(Calendar.MONTH, -6); ... |
Date | getPreviousDate(Date date) Get the previous date Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(java.util.Calendar.DAY_OF_YEAR, -1);
return calendar.getTime();
|
Date | getPreviousDate(final Date date) Get the date for the day previous to that specified. return getOffsetDate(date, -1, Calendar.DATE);
|
Date | getPreviousDate(int period) get Previous Date Date today = new Date(); Calendar calendar = new GregorianCalendar(); calendar.setTime(today); if (period == 7) { calendar.add(Calendar.DATE, -7); } else if (period == 30) { calendar.add(Calendar.MONTH, -1); } else { ... |
Date | getPreviousDateStart() get Previous Date Start Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -2);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();
|