@Override public long getWatermarkIncrementMs() { return new DateTime(0).withFieldAdded(this.incrementalUnit, 1).getMillis(); }
@Override public List<FileInfo> getFilesToProcess(long minWatermark, int maxFilesToReturn) throws IOException { DateTime currentDay = new DateTime().minus(leadTimeDuration); DateTime lowWaterMarkDate = new DateTime(minWatermark); List<FileInfo> filesToProcess = new ArrayList<>(); try { helper.connect(); this.fs = helper.getFileSystem(); } catch (FileBasedHelperException e) { throw new IOException("Error initializing FileSystem", e); } for (DateTime date = lowWaterMarkDate; !date.isAfter(currentDay) && filesToProcess.size() < maxFilesToReturn; date = date.withFieldAdded(incrementalUnit, 1)) { // Constructs the path folder - e.g. /my/data/prefix/2015/01/01/suffix Path sourcePath = constructSourcePath(date); if (this.fs.exists(sourcePath)) { for (FileStatus fileStatus : getFilteredFileStatuses(sourcePath, getFileFilter())) { LOG.info("Will process file " + fileStatus.getPath()); filesToProcess.add(new FileInfo(fileStatus.getPath().toString(), fileStatus.getLen(), date.getMillis())); } } } return filesToProcess; }
DateTime endDt = dateFormatter.parseDateTime(end); int i = 0; for (DateTime dt = startDt; dt.isBefore(endDt) || dt.isEqual(endDt); dt = dt.withFieldAdded( durationType, incr), i++) { this.forwardListObj[0] = dateFormatter.print(dt);
/** * Gets the start instant given the event instant, interval length * and the time zone for this interval type. * * @param instant the event time instant. * @param length the interval length * * @return the start instant of the interval of given length that contains * the supplied time instant in the supplied time zone */ public DateTime getTimeIntervalStart(DateTime instant, long length) { validateValue(instant.getZone(), length); // Reset all the fields DateTime periodStart = instant.property(truncateFieldType) .roundFloorCopy(); // figure out the which time interval does the instant lie in Period period = new Period(periodStart, instant, periodType); DurationField durationField = fieldType.getField(instant.getChronology()).getDurationField(); int diff = period.get(durationField.getType()); long startDelta = (diff / length) * length; return periodStart.withFieldAdded(durationField.getType(), FieldUtils.safeToInt(startDelta)); }
public static DateTime rollForwardWith(ReadableInstant now, AbstractPartial lp) { DateTime dt = lp.toDateTime(now); while (dt.isBefore(now)) { dt = dt.withFieldAdded(lp.getFieldTypes()[0].getRangeDurationType(), 1); } return dt; }
public static void main(String[] args) { DateTime dateTime = FORMATTER.parseDateTime("24/10/2009"); Instant pInstant = dateTime.withFieldAdded(DurationFieldType.days(),2).toInstant(); System.out.println("24/10/2009 + 2 Days = " + pInstant.toString(FORMATTER)); }
@Override public long getWatermarkIncrementMs() { return new DateTime(0).withFieldAdded(this.incrementalUnit, 1).getMillis(); }
@Override public List<FileInfo> getFilesToProcess(long minWatermark, int maxFilesToReturn) throws IOException { DateTime currentDay = new DateTime().minus(leadTimeDuration); DateTime lowWaterMarkDate = new DateTime(minWatermark); List<FileInfo> filesToProcess = new ArrayList<>(); try { helper.connect(); this.fs = helper.getFileSystem(); } catch (FileBasedHelperException e) { throw new IOException("Error initializing FileSystem", e); } for (DateTime date = lowWaterMarkDate; !date.isAfter(currentDay) && filesToProcess.size() < maxFilesToReturn; date = date.withFieldAdded(incrementalUnit, 1)) { // Constructs the path folder - e.g. /my/data/prefix/2015/01/01/suffix Path sourcePath = constructSourcePath(date); if (this.fs.exists(sourcePath)) { for (FileStatus fileStatus : getFilteredFileStatuses(sourcePath, getFileFilter())) { LOG.info("Will process file " + fileStatus.getPath()); filesToProcess.add(new FileInfo(fileStatus.getPath().toString(), fileStatus.getLen(), date.getMillis())); } } } return filesToProcess; }
public Interval getInterval() { final DateTime beginningOfSemester = new DateTime(getAttends().getBegginingOfLessonPeriod()); final DateTime firstMonday = beginningOfSemester.withField(DateTimeFieldType.dayOfWeek(), 1); final DateTime start = firstMonday.withFieldAdded(DurationFieldType.weeks(), getWeekOffset().intValue()); final DateTime end = start.plusWeeks(1); return new Interval(start, end); }
protected DateTime every(DateTime currentTime, DateTimeFieldType unit, int offset, int interval) { DateTime d = currentTime.property(unit).roundFloorCopy(); d = d.withFieldAdded(unit.getDurationType(), offset); return d.withField(unit, (d.get(unit) / interval) * interval); }
curr = time.withFieldAdded(OrgDateTimeUtils.getDurationFieldType(repeater.getUnit()), addUnits); curr = curr.withFieldAdded( OrgDateTimeUtils.getDurationFieldType(repeater.getUnit()), repeater.getValue()
Date dateMin = new DateTime().withFieldAdded(DurationFieldType.days(), -1).toDate(); for (ArticleDto newerLocalArticle : newerLocalArticles) { if (!newerArticleGuids.contains(newerLocalArticle.getGuid()) && newerLocalArticle.getCreateDate().after(dateMin)) {