def localize_datetime(datetime_obj, tz=pytz.utc):
    """Converts a naive or UTC-localized date into the provided timezone.

    :param datetime_obj: The datetime object.
    :type datetime_obj: datetime
    :param tz: The timezone. If blank or None, UTC is used.
    :type tz: datetime.tzinfo
    :return: The localized datetime object.
    :rtype: datetime
    """
    if not datetime_obj.tzinfo:
        return tz.localize(datetime_obj)
    else:
        try:
            return datetime_obj.astimezone(tz)
        except OverflowError:
            if datetime_obj < datetime(2, 1, 1, tzinfo=pytz.utc):
                return MIN_DATE.astimezone(tz)
            return MAX_DATE.astimezone(tz)