List of utility methods to do Date Previous
Date | getPreviousDay(Date date) Get the previous day date-time relative to the provided current date-time. return getNthPreviousDay(date, 1);
|
Date | getPreviousDay(Date dateTime) get Previous Day return addDay(dateTime, -1);
|
Date | getPreviousDay(Date inputDate) get Previous Day Calendar calendar = getCalendar(inputDate);
calendar.add(Calendar.DAY_OF_MONTH, -1);
return calendar.getTime();
|
Date | getPreviousFriday(final Date d) Finds the Friday preceding the date. Calendar cal = getStockExchangeCalendar(); cal.setTime(d); int dow = cal.get(Calendar.DAY_OF_WEEK); cal.add(Calendar.DAY_OF_WEEK, -(dow + 1) % 7); return cal.getTime(); |
Date | getPreviousMonday(Date day) get Previous Monday Calendar previousMonday = Calendar.getInstance(); previousMonday.setTime(day); previousMonday.set(Calendar.HOUR_OF_DAY, 0); previousMonday.set(Calendar.MINUTE, 0); previousMonday.set(Calendar.SECOND, 0); previousMonday.add(Calendar.DATE, -1); previousMonday.add(Calendar.WEEK_OF_MONTH, -1); previousMonday.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); ... |
Date | getPreviousMonth(Date time) get Previous Month Calendar calendar = Calendar.getInstance(); if (null != time) { calendar.setTimeInMillis(time.getTime()); calendar.add(Calendar.MONTH, -1); return new Date(calendar.getTimeInMillis()); |
long | getPreviousMonth(long date) Returns the previous month. return incrementMonth(date, -1);
|
Date | getPreviousMonthFirst(Date appointDate) get Previous Month First Calendar appointCalendar = Calendar.getInstance();
appointCalendar.setTime(appointDate);
Calendar lastDate = Calendar.getInstance();
lastDate.set(Calendar.DATE, 1);
lastDate.set(Calendar.MONTH, appointCalendar.get(Calendar.MONTH) - 1);
lastDate.set(Calendar.YEAR, appointCalendar.get(Calendar.YEAR));
return lastDate.getTime();
|
Date | getPreviousQuarterStartDate(Date dt) Gets the start date for the previous quarter Calendar cal = Calendar.getInstance(); cal.setTime(dt); int calMonth = cal.get(Calendar.MONTH); int calMonthMod = (calMonth) % 3; cal.add(Calendar.MONTH, -(calMonthMod + 3)); cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH)); return dayStart(cal.getTime()); |
Date | getPreviuosRoundMonth(Date baseDate) Description:Get the date after the base date passed in as first parameter and interval is specified by second parameter Calendar calendar = Calendar.getInstance();
calendar.setTime(baseDate);
calendar.set(Calendar.DATE, 1);
calendar.set(Calendar.HOUR, 0);
calendar.set(Calendar.MINUTE, 0);
Date resultDate = calendar.getTime();
return resultDate;
|