-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Filtering (FullTextFilterDef for Date field Hibernate Search
PostPosted: Thu Mar 25, 2010 9:40 pm 
Newbie

Joined: Fri Mar 19, 2010 7:00 pm
Posts: 14
OK so I wrote a full text filter where I want to compare/check a Date field that has been indexed (and corresponds to a DATETIME field in a DB table).

I am having a problem however in my filter. Here is the code for that part:

Code:
int doc = termDocs.doc();
Document document = reader.document(doc);
String testValue = document.get(field);


the String testValue gets the DATETIME field but it contains strings in the following format:

Quote:
20100313020049000
20100313020052000
20100313020054000
20100313020056000
20100313020100000
20100313020102000


according to this http://docs.huihoo.com/hibernate/annotations-reference-3.2.1/lucene.html "Dates are stored as yyyyMMddHHmmssSSS in GMT time (200611072203012 for Nov 7th of 2006 4:03PM and 12ms EST)", so I am guessing that is the reason for that.

MY problem is how can I get an actual Date object OR "long millisecond" variable from a String with format 20100313020049000 (convert from 20100313020049000 to Date or a millisecond timestamp? I've been trying to figure this out for a while now with no progress.

Please help!


Top
 Profile  
 
 Post subject: Re: Filtering (FullTextFilterDef for Date field Hibernate Search
PostPosted: Fri Mar 26, 2010 4:13 am 
Pro
Pro

Joined: Wed Oct 03, 2007 2:31 pm
Posts: 205
Try:

http://lucene.apache.org/java/3_0_1/api ... Tools.html

DateTools is also available in 2.4.1. , I'm guessing you want:
DateTools.stringToDate(String dateString) which turns the string into a Date object.

Thanks
Amin


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.