lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <>
Subject Re: DateTools question
Date Wed, 26 Apr 2006 18:16:14 GMT

: Why does DateTools.dateToString() return a String representation of my Date,
: but in a different TimeZone. Does it use its own Calendar/TimeZone settings?

Yes, DateTime is hardcoded to use GMT for it's string representations.

It wouldn't be safe for DateTools to use your current TimeZone/Locale,
because once you've indexed the value, your index might be used by another
application (or another instance of your application) running in a
differnet locale.

The important thing is not what string DateTools.dateToString returns,
it's whether you get an equivilent date back (based on the resolution you
specified)) when you do something like this...

  Date a = ...;
  DateTools.Resolution r = ...;
  Date b = DateTools.stringToDate(DateTools.dateToString(a,r));
  System.out.println("Is '"+a+"' the same as '"+b+"' with "+r+" resolution?");


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message