I'm sorry. I thought you wanted to parse a date stored as string into a java.util.Date. Clearly, you are trying to go the other way round.
There's nothing in DIH which will convert a mysql date to a string in specific format. You will need to write a custom transformer either in javascript or in java to do this. http://wiki.apache.org/solr/DIHCustomTransformer http://wiki.apache.org/solr/DataImportHandler#ScriptTransformer On Mon, Dec 16, 2013 at 1:34 PM, manju16832003 <manju16832...@gmail.com> wrote: > OK here are the scenarios I tried. > > *Scenario - 1: * > > dih.xml (aka data-config.xml) > > <entity dataSource="solr" name="listing" query="..." > transformer="DateFormatTransformer"> > > <field name="publish_date" column="publish_date" > xpath="/RDF/item/date" > dateTimeFormat="<b>yyyy-MM-dd'T'HH:mm:ss*" locale="en"/> > > schema.xml > <field name="publish_date" type="date" indexed="true" stored="true" > multiValued="false" default="NOW" /> > > It does not work. Throws an following exception > WARN org.apache.solr.handler.dataimport.DateFormatTransformer – Could not > parse a Date field > java.text.ParseException: Unparseable date: "2013-12-05 15:40:03.0" > > *Scenario - 2* > dih.xml (aka data-config.xml) > > <entity dataSource="solr" name="listing" query="..." > transformer="DateFormatTransformer"> > > <field name="publish_date" column="publish_date" > xpath="/RDF/item/date" dateTimeFormat="<b>yyyy-MM-dd > HH:mm:ss*" locale="en"/> > > schema.xml > <field name="publish_date" type="date" indexed="true" stored="true" > multiValued="false" default="NOW" /> > > Output is > <date name="publish_date">2012-12-05T07:38:27Z</date> > > *Scenario - 3* > dih.xml (aka data-config.xml) > > <entity dataSource="solr" name="listing" query="..." > transformer="DateFormatTransformer"> > > <field name="publish_date" column="publish_date" > xpath="/RDF/item/date" dateTimeFormat="<b>yyyy-MM-dd > HH:mm:ss*" locale="en"/> > > schema.xml > <field name="publish_date" type="string" indexed="true" stored="true" > multiValued="false" default="NOW" /> > > Output is > <str name="publish_date">Thu Dec 05 15:38:27 MYT 2013</str> > > My expectation was *2012-12-05 07:38:27* (MySQL DateTime format) > > > > -- > View this message in context: > http://lucene.472066.n3.nabble.com/Storing-MYSQL-DATETIME-field-in-solr-as-String-tp4106836p4106854.html > Sent from the Solr - User mailing list archive at Nabble.com. -- Regards, Shalin Shekhar Mangar.