/** * Given a period, and a date that falls within that period, create a range of dates such * that the period is contained exactly within [startDate <= {range} < endDate] * * @param date a calendar object of a date falling in that range * @param period something in CALENDAR_PERIODS * @return resulting range of dates */ public static DateRange toDateRange(Calendar date, int period) { // defensively copy the calendar so we don't break anything outside. Calendar cal = (Calendar) date.clone(); toStartOfPeriod(cal, period); Date startDate = new Date(cal.getTimeInMillis()); cal.add(period, 1); Date endDate = new Date(cal.getTimeInMillis()); return new DateRange(startDate, endDate); }
/** * Given a period, and a date that falls within that period, create a range of dates such * that the period is contained exactly within [startDate <= {range} < endDate] * * @param date a calendar object of a date falling in that range * @param period something in CALENDAR_PERIODS */ public static DateRange toDateRange(Calendar date, int period) { // defensively copy the calendar so we don't break anything outside. Calendar cal = (Calendar) date.clone(); toStartOfPeriod(cal, period); Date startDate = new Date(cal.getTimeInMillis()); cal.add(period, 1); Date endDate = new Date(cal.getTimeInMillis()); return new DateRange(startDate, endDate); }
@Override public DateRange getDurationToRecover() { Date latestIndexDate = getLatestIndexDate(null); Date latestDbDate = getLatestDbDate(); if (latestDbDate == null || latestIndexDate == null) { return null; } LOG.info(String.format("Latest index date: {%1$tF %1$tT}, Latest DB date: {%2$tF %2$tT}", latestIndexDate, latestDbDate)); return new DateRange(latestIndexDate, latestDbDate); }
if (latestDbDate != null) dateRange = new DateRange(startTime, latestDbDate); LOG.info(String.format("Re-index start time: {%1$tF %1$tT.%1$tL}, Latest DB date: {%2$tF %2$tT.%2$tL}", startTime, latestDbDate));