@Udf(description = "Adds a duration to a date")
  public Date dateAdd(
      @UdfParameter(description = "A unit of time, for example DAY") final TimeUnit unit,
      @UdfParameter(description = "An integer number of intervals to add") final Integer interval,
      @UdfParameter(description = "A DATE value.") final Date date
  ) {
    if (unit == null || interval == null || date == null) {
      return null;
    }
    final long epochDayResult =
        TimeUnit.MILLISECONDS.toDays(date.getTime() + unit.toMillis(interval));
    return new Date(TimeUnit.DAYS.toMillis(epochDayResult));
  }
@Test
  public void shouldAddToDate() {
    assertThat(udf.dateAdd(TimeUnit.DAYS, 9, new Date(86400000)), is(new Date(864000000)));
    assertThat(udf.dateAdd(TimeUnit.DAYS, -1, new Date(86400000)), is(new Date(0)));
    assertThat(udf.dateAdd(TimeUnit.SECONDS, 5, new Date(86400000)), is(new Date(86400000)));
  }