@Override
  public Object evaluate(DeferredObject[] arguments) throws HiveException {
    Date d = getDateValue(arguments, 0, converters);
    if (d == null) {
      return null;
    }

    lastDay(d);
    output.set(date.toString());
    return output;
  }
GenericUDFLastDay.

Returns the last day of the month which the date belongs to.
The time part of the date will be  ignored.
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFLastDay.java