<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_solr_date(pydate, is_negative):
 """ Returns a date in a valid Solr format from a string. """

    # check if date is valid and then set it to solr format YYYY-MM-DDThh:mm:ssZ
    try:
        if isinstance(pydate, datetime.datetime):
            solr_date = '%sZ' % pydate.isoformat()[0:19]
            if is_negative:
                LOGGER.debug('%s This layer has a negative date' % solr_date)
                solr_date = '-%s' % solr_date
            return solr_date
        else:
            return None
    except Exception, e:
        LOGGER.error(e, exc_info=True)
        return None