title: How to create a generic date formatter in java for Solr?
body: <p>I've a requirement where date can be passed in the following formats before indexing them to Solr. Here are the examples of dates being passed 
      <pre><code>String dateStr = "2012-05-23T00:00:00-0400";
  String dateStr1 = "May 24, 2012 04:57:40 GMT";
  String dateStr2 = "2011-06-21";
      </code></pre>
  The standard Solr format is <strong>"yyyy-MM-dd'T'HH:mm:ss'Z'"</strong>. </p>
  
  <p>I've tried SimpleDateFormat but is not able to write a generic program to support various formats. It ends up throwing parse exceptions.</p>
  
  <p>I also tried joda time, but not been succeful so far in UTC conversion.
      <pre><code>public static String toUtcDate(final String iso8601) {
          DateTime dt = ISO_PARSE_FORMAT.parseDateTime(iso8601);
          DateTime utcDt = dt.withZone(ZONE_UTC);
          return utcDt.toString(ISO_PRINT_FORMAT);
      }</code></pre></p>
  
  <p>Is there a standard library to achieve this ?</p>
  
  <p>Any pointers will be appreciated.</p>
  
  <p>Thanks</p>