List of utility methods to do Date Before
Date | getDateBeforeOrAfterV2(int idx) get Date Before Or After V return getDateBeforeOrAfter(getFormatDateToDate(getCurrDate()), idx);
|
long | getDateBeforeSomeMinutes(int minute, long timestamp) get Date Before Some Minutes Calendar c = Calendar.getInstance();
c.setTimeInMillis(timestamp);
c.add(Calendar.MINUTE, minute);
return c.getTimeInMillis();
|
String | getDateBeforeTheDay(String day, int num) get Date Before The Day long longtimes = convertStrToDate(day).getTime() - num * MILLISECOND_IN_DAY; Date date = new Date(longtimes); return convertDateToStr(date, YYYYMMDD); |
String | getDateBeforeToday(int num) get Date Before Today long longtimes = System.currentTimeMillis() - num * MILLISECOND_IN_DAY; Date date = new Date(longtimes); return convertDateToStr(date, "yyyy-MM-dd"); |
Date | getDateBeforTwelveMonth() get Date Befor Twelve Month String date = ""; Calendar cla = Calendar.getInstance(); cla.setTime(getCurrentDate()); int year = cla.get(Calendar.YEAR) - 1; int month = cla.get(Calendar.MONTH) + 1; if (month > 9) { date = String.valueOf(year) + C_DATE_DIVISION + String.valueOf(month) + C_DATE_DIVISION + "01"; } else { ... |
Date | getDateTimeAfterOfBeforeHour(Integer AfterOfBeforeHour) get Date Time After Of Before Hour Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); calendar.add(Calendar.HOUR_OF_DAY, AfterOfBeforeHour); return calendar.getTime(); |
Date | getDayBeforeOrAfter2(Date time, int days) get Day Before Or After Calendar calendar = Calendar.getInstance();
calendar.setTime(time);
calendar.add(Calendar.DAY_OF_MONTH, days);
return calendar.getTime();
|
long | getDayFormSomeDay(Date date, int n, boolean before) get Day Form Some Day Calendar cal = new GregorianCalendar(); cal.setTime(date); if (before) { cal.add(Calendar.DATE, -n); } else { cal.add(Calendar.DATE, n); return cal.getTime().getTime(); ... |
int | getDistanceMonthOfTwoDate(Date before, Date after) get Distance Month Of Two Date if (before.compareTo(after) >= 0) { return 0; Calendar calendar1 = Calendar.getInstance(); Calendar calendar2 = Calendar.getInstance(); calendar1.setTime(before); calendar2.setTime(after); int distance = (calendar2.get(Calendar.YEAR) - calendar1.get(Calendar.YEAR)) * 12 ... |
Date | getMinuteBefore(Date date, int minute) get Minute Before Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.MINUTE, -minute);
return calendar.getTime();
|