def METHOD_NAME(self, param):
    date = None
    if param is None:
        return date
    try:
        date = fields.get_date_object(param, "%Y-%m-%dT%H:%M:%S")
    except Exception:
        try:
            date = fields.get_date_object(param, "%Y-%m-%d")
        except Exception:
            raise WrongParameterException(
                "Wrong date format for before argument."
                "Expected format: 2020-01-05T13:23:10 or 2020-01-05"
            )
    return date