You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Bill Snyder <ws...@gmail.com> on 2006/04/26 20:04:18 UTC
DateTools question
Hello,
Why does DateTools.dateToString() return a String representation of my Date,
but in a different TimeZone. Does it use its own Calendar/TimeZone settings?
F.I.
DateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
System.out.println(DateTools.dateToString(format.parse("2006-04-26 07:29:
52.581"),DateTools.Resolution.MINUTE));
will print out
200604261129
Why the 4 hour difference?
Thanks!
--Bill
Re: DateTools question
Posted by Bill Snyder <ws...@gmail.com>.
Makes sense. Thanks for the response!
--Bill
On 4/26/06, Chris Hostetter <ho...@fucit.org> wrote:
>
>
> : 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
>
>
Re: DateTools question
Posted by Chris Hostetter <ho...@fucit.org>.
: 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
How to display a field value
Posted by anton feldmann <an...@uni-bielefeld.de>.
Hi
how do i display the whole field value of an document the query string
is found?
cheers
anton
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org