lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <hossman_luc...@fucit.org>
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?");


-Hoss


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message