code: public static DateValue toDateValue(DateValue dv) {
          return (!(dv instanceof TimeValue) ? dv
                  : new DateValueImpl(dv.year(), dv.month(), dv.day()));
      }
docs: a DateValue with the same year, month, and day as the given instance that
  is not a TimeValue.