/** * Returns the partitions in sorted ascending order which are after the date value * @param localDate * @return * @throws IOException */ private List<LocalDate> listSortedPartitionsAfterDate(final LocalDate localDate) throws IOException { final LocalDate startDate = localDate.plusDays(1); final List<LocalDate> partitions = getExistingPartitions() .stream() .map(dt -> DateUtil.convertToUTCDate(dt.replace(this.partitionKeyName, StringTypes.EMPTY))) .filter(dt -> dt.compareTo(startDate) >= 0) .collect(Collectors.toList()); return partitions; }
? Optional.of(DateUtil.convertToUTCDate( latestCheckPoint.get().getValue().replace(this.partitionKeyName, StringTypes.EMPTY))) : Optional.absent();
@Test public void testConvertToUTCDate() { // We should be able to handle both forward slashes and dashes as separators // since we sanitize the input final String dateStr = "2017-05-01"; LocalDate ld = DateUtil.convertToUTCDate(dateStr); Assert.assertEquals(2017, ld.getYear()); Assert.assertEquals(5, ld.getMonth().getValue()); Assert.assertEquals(1, ld.getDayOfMonth()); final String dateStr2 = "1998-06-10"; LocalDate l2 = DateUtil.convertToUTCDate(dateStr2); Assert.assertEquals(1998, l2.getYear()); Assert.assertEquals(6, l2.getMonth().getValue()); Assert.assertEquals(10, l2.getDayOfMonth()); } }