@Override
    public boolean equals(Object o) {
      if (this == o) {
        return true;
      }
      if (o == null || getClass() != o.getClass()) {
        return false;
      }

      DurationGranularity that = (DurationGranularity) o;

      if (length != that.length) {
        return false;
      }
      if (origin != that.origin) {
        return false;
      }

      return true;
    }
UDFDateFloor.

Abstract class that converts a timestamp to a timestamp with a given granularity.
ql/src/java/org/apache/hadoop/hive/ql/udf/UDFDateFloor.java