I think the confusion here is that when DateTools looks at a Date object and a Resolution, it does it's calculations in GMT (so when you ask what "day" it is at a particular moment, it tells you the current day in GMT, when you ask which month, it tells you the month in GMT, etc...)
This may seem arbitrary, and it is, but it's fixed like that so that no matter what Locale your jvm is configured with, you'll get the same results from an index as everybody else. If you print the Date object with a robust DateFormatter (instead of the default toString()) you'll see what i mean. : Date: Thu, 24 Aug 2006 00:11:17 -0500 : From: Paul Snyder <[EMAIL PROTECTED]> : Reply-To: java-user@lucene.apache.org : To: java-user@lucene.apache.org : Subject: DateTools.set- : : I have a question about DateTools conversions. I am having trouble with : results of trying to store a date truncated to DAY resolution. : : Here is an example. : : ---------------------------------------------------------------------------- : ---- : : OK: : : DateTools.stringToDate(DateTools.dateToString(new Date("01/12/2006"), : DateTools.Resolution.SECOND)) : (java.util.Date) Thu Jan 12 00:00:00 CST 2006 : : NOT OK: : : DateTools.stringToDate(DateTools.dateToString(new Date("01/12/2006"), : DateTools.Resolution.DAY)) : (java.util.Date) Wed Jan 11 18:00:00 CST 2006 : : ---------------------------------------------------------------------------- : ---- : : The problem appears to be on the stringToDate conversion. : : ---------------------------------------------------------------------------- : ---- : : OK: : : DateTools.dateToString(new Date("01/12/2006"), DateTools.Resolution.DAY) : (java.lang.String) 20060112 : : NOT OK: : : DateTools.stringToDate("20060112") : (java.util.Date) Wed Jan 11 18:00:00 CST 2006 : : ---------------------------------------------------------------------------- : ---- : : I assume there is something simple I am missing, please, anybody, WHAT? : : Local time zone is GMT-0600 (CST) : : OS is Redhat E-L 4. : : jre is from Sun jdk 1.4 : : Lucene is lucene-core-2.0.1.jar : : Paul Snyder : Web Programmer : Post-Bulletin Company, L.L.C. : Phone (507) 281-7402 Fax (507) 281-7491 TollFree (800) 562-1758 : http://www.postbulletin.com http://www.pbinternetservices.com : http://www.rochestermn.com : : : : --------------------------------------------------------------------- : To unsubscribe, e-mail: [EMAIL PROTECTED] : For additional commands, e-mail: [EMAIL PROTECTED] : -Hoss --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]